Solved by ptrblck in post #2 
              
              
                Could you try to initialize outputs as a list, and append all out tensors to it. 
Once you are done, create a tensor via outputs = torch.stack(outputs) and return it. 
I assume the creation of outputs as a tensor, which requires gradients might break the computation graph. 
I would assume you’ll get…