If itâ€™s only a tensor (not a Variable for wich you want to keep the trace of operation in order to compute the gradient), you can use numpy, or do it by hand, because I donâ€™t think it is implemented.

Otherwise (if you want to compute the gradient with respect to this assignment), I have no idea how to do it, since mathematically, an assignment is not differentiable at all.

If you dont want to assign, but to just get the values at the inedx targets, you can use index_select: