Hi,
Unfortunately, you will need a loop to get this. Where you provide a vector that contains only a single 1, to get the Jacobian row by row.
Note that we provide a function to do that nicely here: https://pytorch.org/docs/stable/autograd.html#torch.autograd.functional.jacobian 3