import torch t = torch.arange(24).reshape(2, 3, 4) print(t.transpose(0, 1).shape) # torch.Size([3, 2, 4]) — swapped dims 0 and 1 print(t.permute(2, 0, 1).shape) # torch.Size([4, 2, 3]) — full reorder