Hi,
thank you for taking your time to look at my problem!

Not sure what you mean here?
If you function takes a single input, you can just give that to “hessian” and if it takes multiple of them, you can just pass a tuple containing all of them.  hessian(model, x)  in your case should work fine no?

I assumed that if my network has a 2 dimensional input that a tuple of n 1x2 tensors should work as for the example in the documentation. As for my last comment the batch size n is confused for the input dimension, in this can 2.  Does that make more sense?

autograd.grad()  is just running backward mode AD. And so it will create the  grad_outputs  for you only if the output,  u  in your case, is a scalar. In other cases, you will need to provide it explicitly with the value that fits what you want to get.

Ok, I think you found the critical point there. I am going to look into this and update this comment with relevant links. Thank you!