The second order derivative of pytorch functions are not “known” by pytorch, while the first order are coded “by hand” in the backward methods. If you want the second derivative of your whole graph, I’m afraid that you need at least to extend all the functions you use with a method similar to backward for second order derivative, by hands.