@ptrblck I will be glad for your assistance.
Mores, I am having two loss functions while training a network and ran into an issue of "RuntimeError: Trying to backward through the graph a second time, but the saved intermediate results have already been freed. Specify retain_graph=True when calling backward the first time.".  I would like to know if it is okay to pass retain_graph=True only for one of the losses (for proper loss computation) or both knowing that this is computationally expensive.