In your screenshot it seems you are using retain_graph=True. Could you explain this usage and why it’s needed? Often users add this argument to trade one error for another one (which is often the error you are facing now).
Also, you can post code snippets by wrapping them into tree backticks ```, which makes debugging easier.