I think you could transform the posted formula into the pos_weight formula used in nn.BCEWithLogitsLoss as given in the docs 1.
As described, pos_weight is specified as nb_neg/nb_pos and is multiplied with the “positive” part of the loss (left summand). If you divide both summands by lambda_0 in your formula, you would end up with the same loss formulation.