Your debugging sounds correct and I also think that you might be running into a valid class index issue.
To debug the issue properly, iterate the dataset once and check the max. class index in the target tensor.
Once you’ve found it, make sure the model outputs max_class_index+1 logits.