torch.Tensor.view(*shape)
x = torch.randn(4, 4)
print("x size:",x.size())
y = x.view(16)
print("y size:",y.size())
z = x.view(-1, 8) # the size -1 is inferred from other dimensions
print("z size:",z.size())
a = torch.randn(1, 2, 3, 4)
print("a size:",a.size())
b = a.transpose(1, 2) # Swaps 2nd and 3rd dimension
print("b size:",b.size())
c = a.view(1, 3, 2, 4) # Does not change tensor layout in memory
print("c size:",c.size())
print("b equal c:",torch.equal(b, c))