@albanD
Thank you for your quick response!
I do not really understand your first point. Does it mean the function name within the loss class has to be forward()? I use call to make it called automatically as there are more than one fuction in the loss class.
second, if I implement the histogram2d by myself on the tensor, I do not have to write the backward by myself, right?