code: def ret_log_normalize_vec(vec, axis=1):
      log_max = 100.0
      if len(vec.shape) == 1:
          max_val = np.max(vec)
          log_shift = log_max - np.log(len(vec) + 1.0) - max_val
          tot = np.sum(np.exp(vec + log_shift))
          log_norm = np.log(tot) - log_shift
          vec -= log_norm
      else:
          if axis == 1:  # independently normalize each sample
              max_val = np.max(vec, 1)
              log_shift = log_max - np.log(vec.shape[1] + 1.0) - max_val
              tot = np.sum(np.exp(vec + log_shift[:, np.newaxis]), 1)
              log_norm = np.log(tot) - log_shift
              vec = vec - log_norm[:, np.newaxis]
          elif axis == 0:  # normalize each feature
              k = ret_log_normalize_vec(vec.T)
              return k[0].T, k[1]
          else:
              raise ValueError("'%s' is not a supported axis" % axis)
      return vec, log_norm
  
imports: from __future__ import with_statement
  import logging
  import math
  from gensim import utils
  import numpy
  import scipy.sparse
  from scipy.stats import entropy
  from scipy.linalg import get_blas_funcs, triu
  from scipy.linalg.lapack import get_lapack_funcs
  from scipy.special import psi
label_desc: Use image node_id 16 for calling a global function with example usage: ret_log_normalize_vec(vec, axis) and returns: vec,  log_norm, k,  k