How to calculate the weights for the CrossEntropy loss function?

I am not sure what kind of answer you are looking for. Could you specify a bit more, what you want to do.

To address the error message you are getting:
The error tells you, that you have 100 classes (CIFAR100) but only give weights for 4 classes and that you need to give weights for all 100 classes if you want to use the weight parameter of CELoss.