nn.BCEWithLogitsLoss 785 takes a weight and pos_weight argument.
From the docs:

weight ( Tensor  23 , optional ) – a manual rescaling weight given to the loss of each batch element. If given, has to be a Tensor of size nbatch.
pos_weight ( Tensor  23 , optional ) – a weight of positive examples. Must be a vector with length equal to the number of classes.

Is one of these weights what you are looking for?