BCELoss with class weights

Yes, your approach looks generally correct.

A simple choice for pos_weights would be num_negatives / num_positives as it will weight the positive samples so that they have approx. the same influence on the loss.