Could you print the target values of your current batch inside the training loop and check, if they are all in the range [0, nb_classes-1]?
If you run the code with num_workers=0, the last printed target should be the one causing this error.