I think you should provide the pos_weight as a tensor containing the weights for each class.
E.g. in the doc example 114 64 classes are used and pos_weight is defined as:
pos_weight = torch.ones([64])  # All weights are equal to 1

Just by skimming through your code snippets, I think the first approach might be valid.