Hi Ptrblck,
Sorry for the late reply, I was debugging the code and digging into the issue further. I tested couple of things, however it still not resolved.
1- I have the shape of the numberofclasses= 25

2- The Classes of the dataset are from 0 to 24 numeric and also strings are 25 the labels of the dataset
In the code this is how I am getting the value of y:
image826×263 23 KB

3- while debugging this is where it is throwing the error on task_loss:
image1270×55 8.13 KB
y:
image816×32 6.63 KB
I can see the index 16 is already there 

Thank you in advance for your time and guidance.