Hello all, I have an architecture likes

The input is fed to Gen network to generate a fake image (fakeA). I use L1 loss to compute the different between input and fakeA. I called it is lossGen.
The fakeA then is fed to the segmentation network to create a predA. I used cross entropy to compute the loss between the label and predA. I called it is lossSeg
For training, I have two way
lossGen=...
lossSeg=...
loss = lossGen + lossSeg
loss.backward()

Or
lossGen=...
lossGen.backward()
lossSeg =...
lossSeg.backward()

Which way should I use? Note that, the output of the GenA is used as input for Seg network. Thanks