By definition the transpose permutes two dimensions of a vector.
For example if I have a tensor t1 of dimensions (0, 1, ..., i, ..., j, ..., n-1) ~ (dim_0, dim_1, ..., dim_i, ..., dim_j, ..., dim_n-1), transposing the dimensions i and j is the same as transforming t1 into a tensor t2 of dimension (0, 1, ..., i, ..., j, ..., n-1) ~ (dim_0, dim_1, ..., dim_j, ..., dim_i, ..., dim_n-1)
This is done with pytorch as follows: t2 = torch.transpose(t1,i,j) # or t1.transpose(i,j)