Iterating over a symbolic `tf.Tensor` is not allowed: AutoGraph did convert this function
Hi **@saturn-drm** ,
- Sorry for the delay, I tried to run your code on colab using TF v2.9, 2.16.1 and i am not facing any issue. Please find the [gist](https://colab.sandbox.google.com/gist/Venkat6871/5a66577867096254c08ee9ab56831d9c/67323_2-9-2-16-1.ipynb) here for reference.
- And it looks like you are using an older Version of Tensorflow (2.9). Many bugs have been fixed in the latest version. Can you please execute your code using Latest Version (2.16.1) and let us know if the issue still persists?

Thank you! Thank you for the reply. I will try it out as you recommended. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/67323">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/67323">No</a>

### Issue type

Bug

### Have you reproduced the bug with TensorFlow Nightly?

No

### Source

source

### TensorFlow version

tf 2.9

### Custom code

Yes

### OS platform and distribution

Linux Ubuntu 22.04

### Mobile device

_No response_

### Python version

_No response_

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

I have a function as below. I have `N = tf.shape(y_true)[0]` where `y_ture` is `<tf.Tensor 'y_true:0' shape=(None, 8, 6) dtype=float32>`. I later iterate over N as `for i in tf.range(N)`, but get an error.

```
def transform_targets_for_output(y_true, grid_size, anchor_idxs):
    # y_true: (N, boxes, (x1, y1, x2, y2, class, best_anchor))
    print('y-true',y_true)
    N = tf.shape(y_true)[0]
    print('%%%',N)

    # y_true_out: (N, grid, grid, anchors, [x1, y1, x2, y2, obj, class])
    y_true_out = tf.zeros(
        (N, grid_size, grid_size, tf.shape(anchor_idxs)[0], 6))

    anchor_idxs = tf.cast(anchor_idxs, tf.int32)

    indexes = tf.TensorArray(tf.int32, 1, dynamic_size=True)
    updates = tf.TensorArray(tf.float32, 1, dynamic_size=True)
    idx = 0
    for i in tf.range(N):
        for j in tf.range(tf.shape(y_true)[1]):
            if tf.equal(y_true[i][j][2], 0):
                continue
            anchor_eq = tf.equal(
                anchor_idxs, tf.cast(y_true[i][j][5], tf.int32))

            if tf.reduce_any(anchor_eq):
                box = y_true[i][j][0:4]
                box_xy = (y_true[i][j][0:2] + y_true[i][j][2:4]) / 2

                anchor_idx = tf.cast(tf.where(anchor_eq), tf.int32)
                grid_xy = tf.cast(box_xy // (1/grid_size), tf.int32)

                # grid[y][x][anchor] = (tx, ty, bw, bh, obj, class)
                indexes = indexes.write(
                    idx, [i, grid_xy[1], grid_xy[0], anchor_idx[0][0]])
                updates = updates.write(
                    idx, [box[0], box[1], box[2], box[3], 1, y_true[i][j][4]])
                idx += 1

    # tf.print(indexes.stack())
    # tf.print(updates.stack())

    return tf.tensor_scatter_nd_update(
        y_true_out, indexes.stack(), updates.stack())
```

But I get error like this:

```
raise e.with_traceback(filtered_tb) from None
  File "/home/shakey/yolov3-tf2/yolov3_tf2/dataset.py", line 42, in transform_targets_for_output
    for i in tf.range(N):
tensorflow.python.framework.errors_impl.OperatorNotAllowedInGraphError: Iterating over a symbolic `tf.Tensor` is not allowed: AutoGraph did convert this function. This might indicate you are trying to use an unsupported feature.
```

How can I solve that?

### Standalone code to reproduce the issue

```shell
nothing.
```


### Relevant log output

_No response_