If loss_a and loss_b are not sharing the computation graph (besides the final addition to err in the first approach) and if the optimizers (in the second approach) are also not sharing any parameters, I think the approaches should be equal. At least I don’t see how they could interact.