code: def any2sparse(vec, eps=1e-9):
      """Convert a numpy.ndarray or `scipy.sparse` vector into the Gensim bag-of-words format.
  
      Parameters
      ----------
      vec : {`numpy.ndarray`, `scipy.sparse`}
          Input vector
      eps : float, optional
          Value used for threshold, all coordinates less than `eps` will not be presented in result.
  
      Returns
      -------
      list of (int, float)
          Vector in BoW format.
  
      """
      if isinstance(vec, np.ndarray):
          return dense2vec(vec, eps)
      if scipy.sparse.issparse(vec):
          return scipy2sparse(vec, eps)
      return [
          (int(fid), float(fw)) for fid, fw in vec if np.abs(fw) > eps
      ]
  
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 7 for calling a global function with example usage: any2sparse(vec, eps) and returns: unknown, dense2vec, scipy2sparse