Actauly I have not callled torch.detach() nor I have trasnformed any tensor to numpy or python literal.
It is like when i am trying to do Higher order differencation of tensors it is giving me error on them.
For me : HVP_Y = torch.autograd.grad(inputs =y,outputs =DerivateX_g ,grad_outputs=B_X, retain_graph =True, allow_unused = True) is the place where i am getting the error at in my code.