How do I write latex in this forum?
BCELoss() takes two vectors: x and y. Each of size N. We then have:
l(x, y) = L = {l_1, …, l_N} wheras
l_n = -w_n * [y_n * log(x_n) + (1- y_n) *log(1 - x_n)]
which is linear. Once we got L we make a reduction. This reduction can be the mean or a sum.
This is the reason people apply the BCELoss() batch wise. The reduction is what puts the information from the whole set into a statement.
In short: I can’t see your argument and I can’t see why there is no weights function in the forward function. I mean, what I could do is simple:

Call BCELoss() with reduction=‘none’ and implement my own reduction.

But still, I must be missing something because if my argument would be correct, I could provide w_n to forward().