If `probs` is zero then `log_probs` will be negative infinity, and the
calculation of `neg_entropy` would then give NaN because zero times
infinity is a mathematically indeterminate value.
We need to use nansum so that those NaN values are treated as zeros to
ignore them in the entropy calculation.