torch.unsqueeze is not an inplace operation so either assign the result to a tensor or use the inplace version as tensor.unsqueeze_().
torch.unsqueeze is not an inplace operation so either assign the result to a tensor or use the inplace version as tensor.unsqueeze_().