At issue is that index contains many duplicate values so you are therefore
attempting to write to the same location in data_store multiple times in a
single assignment operation. Doing so is not supported by pytorch and is
not well defined.
Why you get different results from nearly identical assignment statements
is a bit of a mystery – pytorch is presumably taking advantage of the
freedom given it not to attempt to make the multiple write well defined to
perform some optimization (especially on the gpu).