Solved by albanD in post #2 
              
              
                Hi, 
Here is an example implementation. 
Gradients will flow as expected for the copied values from A to B (not gradient for indices of course). 
Note that inplace operations sometimes prevent the autograd from being able to compute gradients so there is a flag in case you encounter this error. 
Let…