import torch x = torch.LongTensor([[1, 2], [3, 4]])
y = x.repeat(1, 5)
tensor([[1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [3, 4, 3, 4, 3, 4, 3, 4, 3, 4]])
z = x.repeat(3, 1)
tensor([[1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4]])In both cases, the `repeat` function takes two arguments as input: the number of times to repeat each element along the rows and columns respectively. Overall, the `repeat` function is a useful tool to efficiently create tensors with repeated elements along a certain dimension.