A single-class classification wouldn’t make much sense, since your model wouldn’t learn anything and will just output a high probability for the single class.
A “perfect” classifier would thus be:
def predict():
    return 0

as no other class indices are valid.
Assuming you are dealing with a binary classification, you could treat it as a 2-class multi-class classification (i.e. with nn.CrossEntropyLoss as the criterion) and use 2 output values or alternatively you could use a single output neuron and use nn.BCEWithLogitsLoss. The lower the output value of this neuron the more likely class0, the higher the more likely class1 was detected.