what I do is
totalLoss = g_cost +  G_mseCost
totalLoss.backward()

and then I take the gradient of the total loss
for name, f in G.named_parameters():
before I apply update
g_optimizer.step()
in this case the gradient I’m having is the total gradient. is there a way to get the gradient of one out of them by not doing two backward and if it is the only way how can I do the two backward without inferring again?