code: def spdot(A, B):
      """The same as np.dot(A, B), except it works even if A or B or both
      are sparse matrices.
  
      Parameters
      ----------
      A, B : arrays of shape (m, n), (n, k)
  
      Returns
      -------
      The matrix product AB. If both A and B are sparse, the result will be a
      sparse matrix. Otherwise, a dense result is returned
  
      See discussion here:
      http://mail.scipy.org/pipermail/scipy-user/2010-November/027700.html
  
      """
      if sps.issparse(A) and sps.issparse(B):
          return A * B
      elif sps.issparse(A) and not sps.issparse(B):
          return (A * B).view(type=B.__class__)
      elif not sps.issparse(A) and sps.issparse(B):
          return (B.T * A.T).T.view(type=A.__class__)
      else:
          return np.dot(A, B)
  
imports: import abc
  import warnings
  import numpy
  import scipy.sparse
  import scipy.optimize
  from scipy.optimize import minimize
  from dipy.utils.optpkg import optional_package
label_desc: Use image node_id 1 for calling a global function with example usage: spdot(A, B) and returns: unknown, unknown, unknown, np