     TypeError: len is not well defined for a symbolic Tensor (rnn_decoder_1/gru_1/Squeeze:0). Please call `x.shape` rather than `len(x)` for shape information.
@ViratCh04, 
Looks like this is an issue from the Keras side. Also there is an [issue](https://github.com/keras-team/keras/issues/19754) raised in the Keras-team/Keras repo for the similar error on the RNN_decoder/gru and assigned to the Developer. Kindly take a look and try to follow the same for the quick response. Thank you! Oh alright @tilakrayal. Thanks for your response. I will try to contribute towards this issue there then! 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/68690">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/68690">No</a>

### Issue type

Bug

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

No

### Source

source

### TensorFlow version

2.15

### Custom code

Yes

### OS platform and distribution

_No response_

### 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 am trying to train my encoder-decoder(GRU) with attention mechanism but on calling the ```@tf.function()``` `trainStep()`, tf gives this error where it claims to be unable to measure a tensor's length using len and refers me to use tf.shape() instead. How can one do such changes in a package's code on a cloud compiler if there is no workaround for this?

Please let me know if I have to provide more resources to address this problem as this is my first raised issue on github

### Standalone code to reproduce the issue

```shell
https://www.kaggle.com/code/viratchauhan/image-captioner-with-visual-attention
```


### Relevant log output

```shell
TypeError                                 Traceback (most recent call last)
Cell In[41], line 9
      6 totalLoss = 0
      8 for(batch, (imgTensor, target)) in enumerate(dataset):
----> 9     batchLoss, tLoss = trainStep(imgTensor, target)
     10     totalLoss += tLoss
     12     if batch % 100 == 0:

File /opt/conda/lib/python3.10/site-packages/keras/src/layers/rnn/rnn.py:423, in RNN.call(self, sequences, initial_state, mask, training)
    420     output = last_output
    422 if self.return_state:
--> 423     if len(states) == 1:
    424         state = states[0]
    425         return output, state

TypeError: in user code:

    File "/tmp/ipykernel_25/1943535969.py", line 17, in trainStep  *
        predictions, hidden, _ = decoder(decoderInput, features, hidden)
    File "/opt/conda/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py", line 113, in error_handler  **
        return fn(*args, **kwargs)
    File "/opt/conda/lib/python3.10/site-packages/keras/src/layers/rnn/gru.py", line 580, in call
        return super().call(
    File "/opt/conda/lib/python3.10/site-packages/keras/src/layers/rnn/rnn.py", line 423, in call
        if len(states) == 1:

    TypeError: len is not well defined for a symbolic Tensor (rnn_decoder_1/gru_1/Squeeze:0). Please call `x.shape` rather than `len(x)` for shape information.
```
