Empty Data Batches Passed to Custom Layer
Hi @Amzo ,

Thanks for reporting.Unfortunately I don't have access to the source you provided. If possible provide the code snippet in the form of gist which can accessed by all. Thanks! I've updated permissions on the original notebook so that it is accessible, if still not accessible I can create a gist. Hi @Amzo,

I have replicated the reported behaviour. The code works fine with TF2.10 but failing with Tf2.12 and tf-nightly as well. 

Please refer to attached gists [2.10v](https://colab.research.google.com/drive/1WYVyMANTPQXEnAVfV-cNO0f5OZclmLwC?resourcekey=0-rBUY0Wn3JuCUmW6FHXVErA) , [2.12v](https://colab.research.google.com/gist/SuryanarayanaY/c8ff57e4eb48adbbe6ea9fb8ceaa8eb8/60523_2-12.ipynb) and [tf-nightly](https://colab.research.google.com/gist/SuryanarayanaY/cfa165c6682618a9fb778c4031f4b1eb/60523_nightly-2-14-0-dev20230508.ipynb).

It needs to dig into more for the root cause. Thanks! This could be due to the recent changes in the Keras saving format since 2.11 version mentioned in the commit here https://github.com/keras-team/keras/commit/c9068087d9142bab573e0c300bf9874a957accff.

 This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. 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/60523">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/60523">No</a>

<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Bug

### Have you reproduced the bug with TF nightly?

No

### Source

binary

### Tensorflow Version

2.12.0

### Custom Code

Yes

### OS Platform and Distribution

Linux 5.10.147

### Mobile device

_No response_

### Python version

3.10.11

### Bazel version

_No response_

### GCC/Compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current Behaviour?

When using a Data Generator with a Custom layer, the data passed to the layer call method is empty. 

However, the same code works as intended in tensorflow 2.10.0, and only seems to pass empty batches to the call method in a custom layer in 2.12.0.

I have a attached a notebook showing the issue. It first runs the code using tensorflow 2.12.0, then downgrades to tensorflow 2.10.0 then reruns the same notebook, and the error is gone.


### Standalone code to reproduce the issue

```shell
https://colab.research.google.com/drive/1E1lDWQWKbo6t0VQmzGEFwSEOCxTJ3t2S?usp=sharing
```


### Relevant log output

```shell
ValueError: in user code:

    File "/usr/local/lib/python3.10/dist-packages/keras/engine/training.py", line 1284, in train_function  *
        return step_function(self, iterator)
    File "/usr/local/lib/python3.10/dist-packages/keras/engine/training.py", line 1268, in step_function  **
        outputs = model.distribute_strategy.run(run_step, args=(data,))
    File "/usr/local/lib/python3.10/dist-packages/keras/engine/training.py", line 1249, in run_step  **
        outputs = model.train_step(data)
    File "/usr/local/lib/python3.10/dist-packages/keras/engine/training.py", line 1050, in train_step
        y_pred = self(x, training=True)
    File "/usr/local/lib/python3.10/dist-packages/keras/utils/traceback_utils.py", line 70, in error_handler
        raise e.with_traceback(filtered_tb) from None
    File "/tmp/__autograph_generated_fileny5tmqhi.py", line 13, in tf__call
        patches = ag__.converted_call(ag__.ld(tf).reshape, (ag__.ld(patches), [ag__.ld(batch_size), -1, ag__.ld(patch_dims)]), None, fscope)

    ValueError: Exception encountered when calling layer 'patches' (type Patches).
    
    in user code:
    
        File "<ipython-input-4-1c4669f3e34b>", line 16, in call  *
            patches = tf.reshape(patches, [batch_size, -1, patch_dims])
    
        ValueError: Tried to convert 'shape' to a tensor and failed. Error: None values not supported.
    
    
    Call arguments received by layer 'patches' (type Patches):
      • images=tf.Tensor(shape=(None, 224, 224, None), dtype=float32)
```
</details>