Thanks a lot, how would it handle duplicate indices? Is the gradient accumulated for duplicate in this case? For example if emb.weight has the shape (4, 10) and x = tensor([[0, 0, 0, 1, 1, 1, 1]]) with the shape (1,7).