Solved by ptrblck in post #2 
              
              
                This code should work: 
x = torch.zeros(100, 64, 32, 32)
mask = torch.tensor([1,2,3,4])
x[:, mask] = 1

Note that I changed the assignment to a 1, otherwise you would reassign a 0 to the tensor containing all zeros.