label might be a scalar value and this tensor(label) might be a 0-dim tensor:
label = 0
label = torch.tensor(label).unsqueeze(1)
> IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)

In that case you would need to either unsqueeze in dim0 or pass the scalar value packed in a list:
label = 0
label = torch.tensor(label).unsqueeze(0).unsqueeze(1)
label = torch.tensor([label]).unsqueeze(1)