Based on the description it seems you are working on a multi-label classification, where zero, one, or multiple classes can be active for each sample.
In that case, you could use nn.BCEWithLogitsLoss as the criterion and get the predictions using a threshold either on the logits or probabilities:
output = model(x)
preds = output > 0.0
# or
preds = torch.sigmoid(output) > 0.5

where the threshold can be defined as you wish.