albanD:

Note that in pytorch, all functions will be differentiated and give you gradients. The only exception is .detach() that is defined as setting all gradients to 0 and the ops inside a torch.no_grad() block that are not tracked.


So is .detach() the correct way to create new “leaf nodes”?
Btw, thank for the help!