The first method was posted in 2018 where pos_weight was most likely not implemented, so don’t need to use the manual approach anymore by multiplying the weight tensor to the unreduced loss.
From the docs 12 for nn.BCEWithLogitsLoss:

For example, if a dataset contains 100 positive and 300 negative examples of a single class, then pos_weight for the class should be equal to 300/100=3. The loss would act as if the dataset contains 3* 100=300 positive examples.

So for your binary classification use case you should pass a tensor with a single element to the criterion.