If the target is one-hot encoded and you are dealing with 10 classes, you can create the class indices via:
torch.argmax(targets, dim=1)

If that’s not the case, I would need more information what the dimensions of the target refer to.