Solved by francois-rozet in post #2 
              
              
                topk returns the k top values and their indices. Indices start at 0. So if you have N classes, their respective indices are 0, 1, 2, ..., N - 1. 
By the way, instead of x.to("cpu") you can use x.cpu().