If you are just using PyTorch operations, Autograd will be able to calculate the backward pass automatically (at least for most PyTorch operations).
You just need to write your own backward method, if you’re using non-PyTorch functions e.g. from numpy.