Yes, if your final output is an integer (that will be an index), then ofc it’s not differentiable (functions that outputs integers are not).
Why do you need to do something like this ?
If you’re training a classifier, you can just output a softmax, and train it to be the one hot encoding of your true label