The usage of a WeightedRandomSampler is independent of the used loss function.
For e.g. nn.CrossEntropyLoss, the reduction='mean' uses

The losses are averaged across observations for each minibatch.

as explained in the docs 14.