Check the inputs you are passing to torch.stack, they should be of same size. The error message says they are of different size.
Use this example as reference
a = torch.randn(4,3)
b = torch.randn(4,3)

c = torch.stack([a,b])
c.shape
# torch.Size([2, 4, 3])