code: def get_inv_matvec(M, symmetric=False, tol=0):
      if isdense(M):
          return LuInv(M).matvec
      elif isspmatrix(M):
          if isspmatrix_csr(M) and symmetric:
              M = M.T
          return SpLuInv(M).matvec
      else:
          return IterInv(M, tol=tol).matvec
  
imports: from scipy.sparse.linalg.eigen.arpack import _arpack
  import numpy
  from scipy.sparse.linalg.interface import aslinearoperator, LinearOperator
  from scipy.sparse import identity, isspmatrix, isspmatrix_csr
  from scipy.linalg import lu_factor, lu_solve
  from scipy.sparse.sputils import isdense
  from scipy.sparse.linalg import gmres, splu
  import scipy
  import functools
  import operator
  from distutils.version import LooseVersion
label_desc: Use image node_id 3 for calling a global function with example usage: get_inv_matvec(M, symmetric, tol) and returns: LuInv, SpLuInv, IterInv