Thanks I got it…I have define two separate neural network in separate class so I thought I don’t need to keep retain_graph=True as both are different neural network class. Loss1 and Loss2 is calculated using output of both neural network and I want to separately back propagate Loss1 to first neural network and Loss2 to second neural network. Is it OK what I did in  question? WIthout retain_graph =True it throws the  error
"
Capture.PNG1540×50 8.65 KB
 "
SO I was forced to keep retain_graph=True…It should work without it right?