This is just the minimal script to reproduce the error. Actually I want to use some given Tensor( learned by KNN) to initialize the center. But I got “a leaf Variable that requires grad has been used in an in-place operation.” , then I learned from https://discuss.pytorch.org/t/in-place-operation-when-indexing-target-variable-with-bytetensor/15839 2, so I include tmp, but it doesn’t work