torch.Tensor.transpose() is not just sugar syntax, but rather torch tensor.permute() is the sugar syntax. While transpose explicitly specifies two dimensions to swap, Pytorch tensor.T completely reverses the shape Size array, essentially a version of permute with reversed size.
tensor.mT is specifically for 2D and only allows 2D tensors.import torch # .T reverses all dimensions x = torch.randn(2, 3, 4) print(x.shape) # torch.Size([2, 3, 4]) print(x.T.shape) # torch.Size([4, 3, 2]) # .mT is for 2D only y = torch.randn(3, 5) print(y.mT.shape) # torch.Size([5, 3]) # transpose swaps two specific dimensions print(x.transpose(0, 2).shape) # torch.Size([4, 3, 2]) # permute reorders dimensions in any order print(x.permute(2, 0, 1).shape) # torch.Size([4, 2, 3]) print(x.permute(2, 1, 0).shape) # torch.Size([4, 3, 2]) - same as .T

Seonglae Cho