code: def safe_sparse_dot(a, b, dense_output=False):
      """Dot product that handle the sparse matrix case correctly
  
      Uses BLAS GEMM as replacement for numpy.dot where possible
      to avoid unnecessary copies.
      """
      if issparse(a) or issparse(b):
          ret = a * b
          if dense_output and hasattr(ret, "toarray"):
              ret = ret.toarray()
          return ret
      else:
          return fast_dot(a, b)
  
imports: from __future__ import division
  from functools import partial
  import warnings
  import numpy
  from scipy import linalg
  from scipy.sparse import issparse, csr_matrix
  from .None import check_random_state
  from .fixes import np_version
  from ._logistic_sigmoid import _log_logistic_sigmoid
  from ..externals.six.moves import xrange
  from .sparsefuncs_fast import csr_row_norms
  from .validation import check_array
  from ..exceptions import NonBLASDotWarning
label_desc: Use image node_id 9 for calling a global function with example usage: safe_sparse_dot(a, b, dense_output) and returns: ret, fast_dot