Hi,
For inplace errors, the anomaly mode points to the operation that saved the Tensor for later use. Not the one that modified it inplace.
But given that it conplains that a LongTensor is faulty. I’m fairly confident in the fact that you change positions inplace later in your code  That would be causing the issue as gather() needs these positions to be able to compute its backward.