Assuming you are using nn.CrossEntropyLoss you could pass the weight argument as described in the docs 1:

weight (Tensor, optional ) – a manual rescaling weight given to each class. If given, has to be a Tensor of size C