Solved by ptrblck in post #2 
              
              
                Assuming you would like to create a mask of shape [B, C], would this work? 
B, C, H, W = 10, 3, 4, 4
x = torch.randn(B, C, H, W)
y = torch.where(x > x.view(B, C, -1).mean(2)[:, :, None, None], torch.tensor([1.]), torch.tensor([0.]))