A quick google search led to this 18 for example. But there are many people doing logistic regression with pytorch. I’m sure you can find an example that suits your needs.
And as I mentionned above, the problem you see is because in the first case you do classification with negative log likelihood loss and so 2*m weights is expected.
In the second case, you change the number of weights with the same loss so this is expected not to work.