nb_classes represents the number of classes you have in your dataset.
Let say you have classes A,B,C and D, nb_classes = 4
Setting the weights could be tricky, but you can first try to set the weights proportionally to theirs appearance in the dataset to overcome the imbalance problem. If you have 20 images of A, 10 images of B and 5 images of both C and D you can try:
weights = torch.one(nb_classes) #nb_classes = 4

weights[0] = 1 #set weight to class A to 1
weights[1] = 2 #set weight to class B to 2...
weights[2] = 4
weights[3] = 4

criterion = nn.CrossEntropyLoss(weight=weights)

You have to change the code if you want to put it on GPU.
Not sure it will be help you, but you could try!
Try to increase the weight decay, and add dropout to overcome overfitting