You are right. The BCELoss is given by:
ℓ(x,y)=L={l1,…, ln,....,lN}⊤, ln = −wn[yn⋅logxn+(1−yn)⋅log(1−xn)]
in this case we invert the above:
weight_label_i = total_number_of_samples / nr_samples_of_label_i