(self, logits, dim)
return max_val + (logits - max_val.unsqueeze(dim)).exp().sum(dim).log()
Computes log-sum-exp in a stable way
Computes log-sum-exp in a stable way
Computes log - sum - exp in a stable way
def _log_sum_exp(self, logits, dim):
        """
        Computes log-sum-exp in a stable way
        """
        max_val, _ = logits.max(dim)
        return max_val + (logits - max_val.unsqueeze(dim)).exp().sum(dim).log()
def _log_sum_exp ( self , logits , dim ) : max_val , _ = logits . max ( dim ) return max_val + ( logits - max_val . unsqueeze ( dim ) ) . exp ( ) . sum ( dim ) . log ( )