For two classes, the usual setup is to take the binary cross entropy loss. PyTorch has nn.BCELoss and nn.BCELossWithLogits for this, the latter including the sigmoid layer that you would need to add to your net for the former. The trick here is that the “probability” of the 0 class is just 1 minus that of the 1 class.
CrossEntropyLoss and friends are for multiple classes, where you can’t do this trick. If you wanted to use that for two classes, you would need to have an output that has size two in the class dimension.
Best regards
Thomas