Thank you for your answer @KFrank ! this was actually my gut feeling but wanted some other opinions.
One further question:
I am recomputing the weights for each minibatch. Does the shown computation of the weights represent the occurences of my labels properly for the CrossEntropyLoss?