# orbit.utils.create_tf_while_loop_fn

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/models/blob/v2.20.0/orbit/utils/loop_fns.py#L92-L126) |

Creates a loop function compatible with TF's AutoGraph loop conversion.

    orbit.utils.create_tf_while_loop_fn(
        step_fn
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `step_fn` | A function taking a nested structure of [`tf.data.Iterator`](https://www.tensorflow.org/api_docs/python/tf/data/Iterator) or `DistributedIterator`. Currently, any return values are ignored. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A loop function taking required `iterator` and `num_steps` parameters. If called inside a [`tf.function`](https://www.tensorflow.org/api_docs/python/tf/function), the loop will be converted by AutoGraph into a [`tf.while_loop`](https://www.tensorflow.org/api_docs/python/tf/while_loop) construct. See the `loop_fn` definition below for additional details. ||

<br />