For a binary classification you could use:

one output value and use nn.BCEWithLogitsLoss

or two outputs and use nn.CrossentropyLoss


Both approaches would work, but are a bit different in their implementation.
While the former is used for a classical binary classification as well as a multi-label classification (each sample might belong to zero, one, or multiple classes), the latter is used for a multi-class classification (each sample belongs to one class only).