Yes, it should (if total.backward()). Try to print and see if they are different?
Since the backward is on total i.e loss1+loss2, the computation graph would include both 1, 2 inputs.
You could also refer the GAN tutorial where something similar is done