Solved by Tony-Y in post #2 
              
              
                >>> import torch
>>> bz=2; h=5; w = 5;
>>> a = torch.zeros(bz, h, w)
>>> idx_1 = torch.tensor([[0,2,1],[2,3,0]])
>>> idx_2 = torch.tensor([[1,2,3],[3,3,4]])
>>> idx_b = torch.arange(bz).long().unsqueeze(1).expand(bz,3)
>>> idx = idx_b * h*w + idx_1 * w + idx_2
>>> b = a.view(bz*h*w)
>>> b[idx] = 1
>>…