Assume you  have a tensor y of size M x 10 and another tensor x of size M. The values of both x and y are integers between 0 and 9.
I want to get a new tensor z of size M which is of the following form:
z[k]= y[k][x[k]]
Is it possible to do this without using a for loop?