after changing y to y-1 in dataset, I tried:
for epoch in range(1):
    net.train()
    for inputs, labels in dataloaders['train']:
        optimizer.zero_grad()
        with torch.set_grad_enabled(True):
            labels.squeeze()
            print (labels)

the output was:

tensor([[1], [1], [3], [2]])

if I add

loss = criterion(outputs, labels)

I get the same error as above