Hi,
An nn.Module is just a convenient construct to handle parameters, buffers, interaction with optimizers in the context of torch.nn
A autograd.Function is a new elementary op in the autograd.
So if you want to specify the backward for a given op, you want a custom autograd.Function. See the doc here 264 on how to do that.