I don't understand this line:
lprobs[lprobs != lprobs] = torch.tensor(-math.inf).to(lprobs)
There is no comment, so is it some well-known Python (or PyTorch?) idiom? Could someone explain what it means, or show a different way that makes the intent clearer?
lprobs
is a pytorch Tensor
, and it could contain any size float type (I doubt this code is intended to support int or complex types). As far as I know, the Tensor classes don't override the __ne__
function.