Hi,
If your loss is differentiable and the gradients you want are the ones that correspond to your forward pass, then you should use the autograd version.
If for performance reasons or because you want different gradients you need a custom backward, you can see this 63 section of the doc about how to do it.