Solved by albanD in post #2 
              
              
                Hi, 
For any number of dimensions, you can use scatter to achieve this: 
import torch

ind= torch.tensor([[[1,3],
                   [0,3],
                   [1,2]],

                  [[0,2],
                   [1,2],
                   [2,3]]])

base = torch.ones(2, 3, 4)

base.scatter_(2, ind, 0…