How to apply weighted loss to a binary segmentation problem?

Thanks for replying @ptrblck

However, in trying to understand how to implement this I came across your post here: About BCEWithLogitsLoss's pos_weights

I applied pos_weight accordingly as an int but I am given an error that it does not expect to receive an int. Searching further lead me here: Weights in BCEWithLogitsLoss

So I am back where I started, how do I apply this weight? or if it is expecting a vector, how do I apply the weights in my binary case?

Thanks