Basic doubt dim in squeeze and unsqueeze

How does dim dim in squeeze and unsqueze work?
x = torch.zeros(2, 1, 2, 1, 2)
x.squeeze()
torch.Size([2, 2, 2])

y=torch.squeeze(x,1)
torch.Size([1, 2, 1, 2, 1, 2]) .//no change

y=torch.squeeze(x,2)
results :-
torch.Size([1, 2, 2, 1, 2])

Hi Sandeep!

torch.squeeze() removes those dimensions of a tensor that have
size = 1. This is explained reasonably clearly in the documentation
for torch.squeeze.

Specifically, if you give squeeze() no dim argument, it removes all
size = 1 dimensions. If you give squeeze() a value for dim, it
removes just that dimension, but only if it has size = 1.

This looks like a typo. Based on the results you give below, I think
this should be x = torch.zeros(1, 2, 1, 2, 1, 2).

Best.

K. Frank