squeeze removes a dimension with a size of 1.
E.g. if you have a tensor with a shape of [2, 1, 3, 1, 4, 1], you could squeeze dim1, dim3, and dim5 by passing the dim argument to squeeze. Calling squeeze() on a tensor without specifying a dimension will remove all dimensions with a size of 1. The docs also explain this behavior.