Based on the error message your weight tensor doesn’t match the number of classes in your use case.
Assuming class_weight is used in the criterion, make sure your model outputs logits for two classes.