<br />

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

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

    tf.inside_function() -> bool

<br />

<br />

<br />

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

<br />

#### Example:

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