tape.gradient computes none after model in model training
can you put your code in detail to solve this issue?
 Hi, @VictorvanWeelden 

Apologize for the delay and I was able to replicate the issue on Google colab with `TF2.11 `and also tried with pre release `tensorflow 2.12.0rc0`, I have added both gist files here [tf-2.11](https://colab.research.google.com/gist/gaikwadrahul8/d697ffdf060179449f5cade41e11ffa8/-59652-tf2-11.ipynb) and [tensorflow 2.12.0rc0](https://colab.research.google.com/gist/gaikwadrahul8/88d44213c3239c8dd0f102e2cb653e44/-59652.ipynb) but I'm also getting the same error but with pre release `tensorflow 2.12.0rc0` I noticed different error `RuntimeError: A non-persistent GradientTape can only be used to compute one set of gradients (or jacobians)` but it got resolved by passing `persistent=True` to `with tf.GradientTape()` so We will have to dig more into this issue and we will update soon here and thank you for noticing this issue. Thank you! This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Thank you.
 Hi, @VictorvanWeelden 

Apologize for the delayed response and It seems like there is some issue while calculating the gradient and it's returning none so for your reference I have added one [gist file](https://colab.research.google.com/gist/gaikwadrahul8/a9665800afb2c2f103925c753c196f6c/-59652.ipynb) which may be one of the reason for tape.gradient computes none after model in model training so could you please have a look into that gist-file and check whether is it resolving your issue ?, if not please let us know for investigation to find out root cause for your issue. Thank you! 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/59652">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/59652">No</a>

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

Bug

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

Yes

### Source

source

### Tensorflow Version

2.11.0

### Custom Code

Yes

### OS Platform and Distribution

_No response_

### Mobile device

_No response_

### Python version

3.8

### Bazel version

_No response_

### GCC/Compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current Behaviour?

```shell
grads = tape.gradient(class_channel, last_conv_layer_output) does produce NONE after performing first a regression on a "inner" model (trained and tested with MNIST and CIFAR10), before freezing the "inner" model network and then training a "outer" model over the "inner" model. After even unfreezing the "inner" model tape.gradient does not produce a result when asking for the final layer of the "inner" model as used in Grad-CAM.
```


### Standalone code to reproduce the issue

```shell
The minimal code is in the link. Everything can be run, till the final cell where the bug is.

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


### Relevant log output

```shell
AttributeError                            Traceback (most recent call last)
<ipython-input-12-17e9c91a6483> in <module>
      4 print(class_channel.shape)
      5 grads = tape.gradient(class_channel, last_conv_layer_output)
----> 6 print(grads.shape)

AttributeError: 'NoneType' object has no attribute 'shape'
```
</details>