Solved by ptrblck in post #2 
              
              
                I’m not sure, if you could use an alternative to a simple for loop  
b, h, w = 2, 4, 4
x = torch.randn(b, 19, h, w)
z = torch.zeros(b, 10, h, w)

dic = {9:[0,1], 8:[3,4], 7:[9,10,11], 6:[6,7,8], 5:[2,5], 4:[18,17,16], 3:[4,5,6], 2:[12,13], 1:[15], 0:[14]}

for key in dic:
    d = dic[key]
    z[:, k…