nn.CrossEntropyLoss() expects raw logits as the model output, as internally F.log_softmax and nn.NLLLoss will be applied, so you should remove the F.softmax in your model.
Also, the target is expected to have the shape [batch_size] and contain class indices in the range [0, nb_classes-1], so these lines of code don’t look right:
one_hot_encoder = OneHotEncoder(categories='auto')
labels = one_hot_encoder.fit_transform(labels).toarray()

Could you check the output and target shapes before calculating the loss, please?