Solved by ptrblck in post #2 
              
              
                Recreating a tensor will break the computation graph in torch.tensor([e]). 
Try to either concatenate this tensor directly, or alternatively append e in a list and call torch.stack on it afterwards.