# tf.inside_function

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/framework/ops.py#L4769-L4787) |

Indicates whether the caller code is executing inside a [`tf.function`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/function).

    tf.inside_function()

<br />

<br />

<br />

| ## Returns ||
|---|---|
| Boolean, True if the caller code is executing inside a [`tf.function`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/function) rather than eagerly. ||

<br />

#### Example:

    tf.inside_function()
    False
    @tf.function
    def f():
      print(tf.inside_function())
    f()
    True