The operation here is index_put with accumulate=False. The manual says " If accumulate is False , the behavior is undefined if indices contain duplicate elements."
https://pytorch.org/docs/stable/tensors.html?highlight=index_put#torch.Tensor.index_put_ 15. Same is true for numpy:
“For advanced assignments, there is in general no guarantee for the iteration order. This means that if an element is set more than once, it is not possible to predict the final result.”
https://docs.scipy.org/doc/numpy/reference/generated/numpy.searchsorted.html 6