You would have to map these indices to [0, nb_classes-1] as described in the previous post.
EDIT: here is a code snippet in case you get stuck:
target = torch.randint(3, 6, (10,))
print(target)
> tensor([3, 4, 3, 3, 3, 5, 5, 4, 3, 4])

unique = torch.unique(target)
for i, u in enumerate(unique):
    target[target==u] = i
print(target)
> tensor([0, 1, 0, 0, 0, 2, 2, 1, 0, 1])