You can use unsqueeze to add another dimension, after which you can use expand:
a = torch.Tensor([[0,1,2],[3,4,5],[6,7,8]])
a.unsqueeze_(-1)
a = a.expand(3,3,10)
This will give a tensor of shape 3x3x10. With transpose you can swap two dimensions. For example, we can swap the first with the third dimension to get a tensor of shape 10x3x3:
A = [[0,1,2], [3,4,5], [6,7,8]] [[9,10,11], [12,13,14], [15,16,17]]
So The dimension is 2 x 3 x 3 (batch size, len, features). How can I now repeat each row batchwise.
Assuming that A is a list, then you can do the following A = torch.tensor(A*10). But if A is a tensor not a list, then you can split A to a list, and then repeat each element and convert it back to tensor: