Solved by George_Stepaniants in post #4 
              
              
                Turns out all I needed was a function like this: 
def deriv(self, t, n=1):
        dx = self.forward(t)
        for i in range(n):
            dx = torch.autograd.grad(outputs=dx, inputs=t, grad_outputs=torch.ones_like(t), create_graph=True)[0]
        return dx