pytorch tensor change dimension order

a = torch.rand(1,2,3,4)
print(a.transpose(0,3).transpose(1,2).size())
print(a.permute(3,2,1,0).size())

Here is what the above code is Doing:
1. a.transpose(0,3) is swapping the 0th and 3rd dimension of a.
2. a.transpose(1,2) is swapping the 1st and 2nd dimension of a.
3. a.permute(3,2,1,0) is swapping the 3rd, 2nd, 1st, and 0th dimension of a.

The output of the above code is:
torch.Size([4, 3, 2, 1])
torch.Size([4, 3, 2, 1])

As you can see, the output of the two methods is the same.