Sorry I should’ve made this a bit clearer, the output of the custom_det function returns [B, ] for an input of [B, N, N]. What I mentioned above was the size of the input matrix, the size of the 1st order gradient w.r.t the input matrix (from the first backward method), and the size of the 2nd order gradient w.r.t the input matrix (from the second backward method).
Also, I think I’ve just realised that the Tensor of [25, 4, 4] could be the grad_output which is returned in the Double Backward method?
Also, also, how exactly do I set TORCH_SHOW_CPP_STACKTRACES=1 ? I saw from this 1 question you state it needs to be enabled before importing torch. Would this be enable via something like this?
import os 
os.environ['TORCH_SHOW_CPP_STACKTRACES'] = "1"
import torch

Thank you
Edit: I’ve added these lines to the code of my code, and nothing has changed with the torchviz diagram. (So I’ve probably implemented it wrong?)