Solved by Pranavan_Theivendira in post #2 
              
              
                Hi, 
You can try this as well. 
import torch

tensor = torch.tensor([1,2,4,6,2,1])
idx = torch.topk(tensor,1)[1]
out = (tensor >= tensor[idx]).type(torch.uint8)

Thanks