It sort of fits the error I am getting the only difference being I am calculating a different output for iteration 2 and a different loss function but the backward is done on the added loss where loss=loss_iter1+loss_iter2. Is there a way I can fix this?