Mendel123:

Does it mean we can only expand the axis with size 1?


Yes, from the docs 54:

Returns a new view of the self tensor with singleton dimensions expanded to a larger size.
[…]
Any dimension of size 1 can be expanded to an arbitrary value without allocating new memory.

You could use x.repeat(2, 1) for your use case. Note that this operation would allocate new memory for the tensor.