How to weight the loss?

Thanks!
but weights.sum() is correct? not the size of batch?