I think the problem occurs due to the successive indexing, which might work on a copy of the tensor.
Could you somehow combine the indexing to just onefor array1?
If you need some help, could you post the shapes of array1 and array2, so that we could have a look?
Currently the second index won’t work, as np.arange(10) and np.arange(5, 10, 1) have different shapes and cannot be summed together.