Thank you very much, @AlphaBetaGamma96
May I ask why y_a = torch.tensor([y1, y2]) didn’t create a torch tensor with a grad_fn attached, although it has the same shape and type as the one created by stacking y1 and y2 as you suggested, i,e. y_b = torch.stack([y1, y2]) as shown below?