z is a tensor which has some values. If z has some value > 3870 in my case, we need to go the tensor x, and find its index. If the value is 3872, the index in tensor x is: [0][2] and its corresponding value in y tensor is 1 i.e., at index [0][2]. We need to substitute 3872’s value in z by corresponding value in y tensor. So, z[0][7] which had value 3872 becomes: 1.