<br />

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

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

```python
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.15/api_docs/python/tf/function.md.txt) rather than eagerly. ||

<br />

#### Example:

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