If all operations in the forward method are differentiable, you could create a custom nn.Module and let Autograd create the backward pass.
autograd.Functions are used for custom forward and backward implementations.