how about this operation:
  v = torch.autograd.Variable(torch.Tensor([0.8,0.1,0.1,0]), requires_grad=True)
  out = (v==torch.max(v).expand_as(v)).float()

does variable v and out have gradients?
@alexis-jacq
@SimonW