What does work torch.cat(dim=2)?

Somewhere, I saw the torch.cat((tensors),dim=2) works.
So I tried under code but it doesn’t working.

a = torch.randn(2,5)
b = torch.randn(3,5)

torch.cat((a,b),dim=2)
RuntimeError: Dimension out of range (expected to be in range of [-2, 1], but got 2)

What does meaning of dim=2?

It is going to try to concatenate across dimension 2 – but dimension numbers, as tensor indexes start at 0 in PyTorch. Thus dim=2 refers to the 3rd dimension, and your tensors are only 2-dimensional.