Actually what came into my mind is that I can calculate the gradient numerically. I know the range of possible values and all are integers, so the epsilon will be 1. The question is how can I join it with the pytorch pipe? Let’s say, there is a model of X layers that outputs 10 parameters. Now I want to put this custom numerical loss on these 10 parameters.