title: Tensorflow2 warning using @tffunction
body: <p>This example code from Tensorflow 2</p>
  
  <pre><code>writer = tf.summary.create_file_writer("/tmp/mylogs/tf_function")
  
  @tf.function
  def my_func(step):
    with writer.as_default():
      # other model code would go here
      tf.summary.scalar("my_metric", 0.5, step=step)
  
  for step in range(100):
    my_func(step)
    writer.flush()
  </code></pre>
  
  <p>but it is throwing warnings. </p>
  
  <blockquote>
    <p>WARNING:tensorflow:5 out of the last 5 calls to  triggered tf.function retracing. Tracing is expensive
    and the excessive number of tracings is likely due to passing python
    objects instead of tensors. Also, tf.function has
    experimental_relax_shapes=True option that relaxes argument shapes
    that can avoid unnecessary retracing. Please refer to
    <a href="https://www.tensorflow.org/beta/tutorials/eager/tf_function#python_or_tensor_args" rel="noreferrer">https://www.tensorflow.org/beta/tutorials/eager/tf_function#python_or_tensor_args</a>
    and <a href="https://www.tensorflow.org/api_docs/python/tf/function" rel="noreferrer">https://www.tensorflow.org/api_docs/python/tf/function</a> for more
    details.</p>
  </blockquote>
  
  <p>Is there a better way to do this?</p>