Thanks for reply @ anantguptadbl.
My example code is just compare between input and output.
I think that torch.autograd calculates the partial derivative of output.
In this case 
where u is  output of network, f is input image and w is parameter of network.
But I don’t know how to calculate    in my custom loss backward function.