Sorry,
I meant to write cat above, I edited my comment.
also the code that is running is not the one you showed, from the stack trace, it is:
     52         print(a.unsqueeze(-1).size(), b.size())
---> 53         print(torch.stack([a, b], dim=1))

where the unsqueeze() is missing in the second call.