code: def logsumexp(a, axis=None):
      """
      Compute the log of the sum of exponentials log(e^{a_1}+...e^{a_n}) of a
  
      Avoids numerical overflow.
  
      Parameters
      ----------
      a : array_like
          The vector to exponentiate and sum
      axis : int, optional
          The axis along which to apply the operation.  Defaults is None.
  
      Returns
      -------
      sum(log(exp(a)))
  
      Notes
      -----
      This function was taken from the mailing list
      http://mail.scipy.org/pipermail/scipy-user/2009-October/022931.html
  
      This should be superceded by the ufunc when it is finished.
      """
      if axis is None:
          # Use the scipy.maxentropy version.
          return sp_logsumexp(a)
      a = np.asarray(a)
      shp = list(a.shape)
      shp[axis] = 1
      a_max = a.max(axis=axis)
      s = np.log(np.exp(a - a_max.reshape(shp)).sum(axis=axis))
      lse = a_max + s
      return lse
  
file_path: statsmodels/statsmodels/sandbox/infotheo.py
imports: from statsmodels.compat.python import lzip, lmap
  from scipy import stats
  import numpy
  from matplotlib import pyplot
  from scipy.special import logsumexp
label_desc: Use image node_id 1 for calling a global function with example usage: logsumexp(a, axis) and returns: lse, sp_logsumexp