Solved by albanD in post #4 
              
              
                I’m still unsure what your goal here is  
But if you want the forward and backward functions, you just need to differentiate the functions. 
For example, you have mse that does this in the forward: mse(x, y) = (x - y).norm(2).mean() 
Then you can differentiate wrt to x and do mse_backward_x(grad_ou…