Met the same problem.
I used torch.reshape in my code, but didn’t use torch.stack.
Replacing torch.reshape with torch.view worked for my case.
Supposedly, this is related to when someone depends on copying vs. viewing behavior 53.
torch.reshape sometimes copies tensors internally, which can make gradient backward path disconnected.
I hope some more detailed guides about when to use and when not to use torch.reshape to be added at docs.

Related stackoverflow question: https://stackoverflow.com/questions/49643225/whats-the-difference-between-reshape-and-view-in-pytorch 52