Solved by eduardo4jesus in post #14 
              
              
                Ok, I understood now what you want. I can’t see an elegant way to have a solution using plain PyTorch. The “naive” way to do it would be via a for loop. 
First, let me redefine what I think you are asking: 

Having an input tensor, and another tensor selection, I want to produce the output tensor as…