I just need to change the labels according to the scores of the features. The features that are used to compute the loss are not modified when they are fed to the cross_entropy. Since labels are input tensors, their values should be easily to be modified.
I change the associated lines into:
            scores = F.softmax(logits, dim=1).cpu().clone().detach()
            labels_cpu = labels.cpu().clone().detach()

But the problem still exists. How could I make it work please?