Sorry, I typed something wrong. HadamardProd does inherit from torch.autograd.Function in my original code.  Thanks for your suggestion. But leaving out the backward function doesn’t work. It raises a NotImplementedError.