Thanks!
But I think I have no idea how torch.autograd.grad does … Does it just return a list of tensors that contains the gradient of f with respect to p?
If that’s the case then this should work for me.