Just as an update: I have managed to fix this issue with the following line
embedded = self.embed(y_pred[:, i-1:i].clone()) if i > 0 else torch.ones_like(y_pred[:, 0:1])

by looking at similar issues online. But I was wondering if someone could explain why this clone() is necessary? Think my conceptual understanding of the autograd engine is letting me down here.
Many thanks,
Jase