Solved by AnBucquet in post #2 
              
              
                Hi @shadowhy , 
You can try this: 
 output = (a == torch.max(a, 1 , keepdim=True)[0])

Let me know if it’s not what you’re looking for.