Solved by ptrblck in post #2 
              
              
                Rewrapping a tensor in torch.Tensor will detach it from the computation graph, so you might want to use torch.cat or torch.stack instead.