You are totally right, let me explain better now (and correct my mistakes)
For example, image I have a dataframe df like this
| var | label
|  a  | 2	
|  b  | 2	
|  c  | 1	
|  d  | 3	

In the example before, I calculated the class weights as
w = 1 / (df.label.value_counts()/df.label.value_counts().sum())
w = w/w.sum()

which leads to this class weight (you are right, number total class not number of samples)
2    0.2
3    0.4
1    0.4

Now, when I pass w to my loss function through torch.from_numpy(w.values), should I first order it so that it reflects the order of the classes (1, 2, 3), therefore [0.4, 0.2, 0.4]? Or should I pass it as-is, therefore [0.2, 0.4, 0.4]?
Hope it’s clearer now, sorry about before!