According to the docs CrossEntropyLoss 12 takes predictions of shape (N, classes) and targets of shape (N).
So yes, CrossEntropyLoss is built to work with indices.
As for bugs, if the code runs without throwing any errors and the predictions get to be reasonably good, then your code is probably mostly bug free.