I had tried with torch.stack() and it didn’t work either. I thought that maybe it is the list comprehension so I tried vectorizing the model resulting grad parameters, but that doesn’t work either. I am not sure if autograd.grad is retaining the graph because when I print it out there is no requires_grad=True attribute:

Screen Shot 2021-07-01 at 11.06.10 AM2760×1170 458 KB