title: What is the relationship between `tf.function` and `autograph.to_graph` in Tensorflow?
body: <p>Similar results can be obtained via <code>tf.function</code> and <code>autograph.to_graph</code>.<br>
  However this seems to be version dependant.</p>
  
  <p>For example, the function (taken from the official guide):</p>
  
  <pre><code>def square_if_positive(x):
    if x &gt; 0:
      x = x * x
    else:
      x = 0.0
    return x
  </code></pre>
  
  <p>Can be evaluated in graph mode using:</p>
  
  <ul>
  <li><code>autograph.to_graph</code> in TF 1.14</li>
  </ul>
  
  <pre><code>tf_square_if_positive = autograph.to_graph(square_if_positive)
  
  with tf.Graph().as_default():
    g_out = tf_square_if_positive(tf.constant( 9.0))
    with tf.Session() as sess:
      print(sess.run(g_out))
  </code></pre>
  
  <ul>
  <li><code>tf.function</code> in TF2.0</li>
  </ul>
  
  <pre><code>@tf.function
  def square_if_positive(x):
    if x &gt; 0:
      x = x * x
    else:
      x = 0.0
    return x
  
  square_if_positive(tf.constant( 9.0))
  </code></pre>
  
  <p>So:</p>
  
  <ul>
  <li>What is the relationship between <code>tf.function</code> and <code>autograph.to_graph</code>? One can assumes <code>tf.function</code> is using <code>autograph.to_graph</code> (as well as <code>autograph.to_code</code>) internally, but this is far from obvious.</li>
  <li>Is the <code>autograph.to_graph</code> snippet still supported in TF2.0 (since it requires <code>tf.Session</code>)? It is present in the <a href="https://www.tensorflow.org/guide/autograph#automatically_convert_python_control_flow" rel="nofollow noreferrer">autograph doc</a> in TF 1.14, but not in the corresponding doc of TF 2.0</li>
  </ul>