RuntimeError: in-place operations can be only used on variables that don't share storage with any other variables, but detected that there are 2 objects sharing it

I have a list of indices. E.g. list_of_nodes = [0 , 2 , 5]. I have a variable node which is of dimension 8x2. Now, I want to put value 1 to every row indicated by list_of_nodes. of the nodes variable. I am using nodes[list_of_nodes] = 1. But it is throwing the runtime error. Can anyone please help?

Note: I am using this variable in a for loop. At each iteration, the value of this ‘nodes’ variable will need to be modified by the process mentioned above.

Can you provide a minimum working example to reproduce your issue?