That was helpful. Thanks. Another question, related to if this a part of the final loss, with more criterion. Currently I’m doing: loss = criterion_1 + loss_g and then loss.backward(). Is this correct? Or it is twice propagated? one in torch.autograd.grad(outputs=V_norm, inputs=X, retain_graph=True) and the other in loss.backward(). Thanks.