Squeeze, unsqueeze explanation

When I went through documentation for squeeze, unsqueeze methods, I felt like I got this clearly and after few days when I start using squeeze and unsqueeze, I feel that I am not totally clear on these two methods.

can anyone shed some light on these two methods please!

unsqueeze to add dimension of size 1,
squeeze to remove dimension of size 1.

for example,

import torch
x = torch.randn(10); x
tensor([-0.9048, -0.3753, -0.3185, -1.4873, -0.7718,  0.6153,  0.1261,  0.5256,
        -1.9678, -0.2045])
x.shape
torch.Size([10])
y = x.unsqueeze(dim=0)
y.shape
torch.Size([1, 10])
y = x.unsqueeze(dim=-1)
y.shape
torch.Size([10, 1])

one more thing,

y = x[None] # or y = x[None, :], same as x.unsqueeze(dim=0)

and

y = x[:, None] # same as x.unsqueeze(dim=-1)

for squeeze, if

y.shape

is

torch.Size([10, 1])

then,

y.squeeze_(dim=1)
y.shape

give

torch.Size([10])