Custom version of logsumexp to make older version of scipy happy.