code: def _is_sparse(x):
      """
  
      Returns
      -------
      boolean
          True iff x is a L{scipy.sparse.spmatrix} (and not a L{numpy.ndarray}).
  
      """
      if not isinstance(
          x, (scipy.sparse.spmatrix, np.ndarray, tuple, list)
      ):
          raise NotImplementedError(
              "this function should only be called on "
              "sparse.scipy.sparse.spmatrix or "
              "numpy.ndarray, not,",
              x,
          )
      return isinstance(x, scipy.sparse.spmatrix)
  
imports: from collections.abc import Iterable
  from typing import Literal, Optional, Union
  import numpy
  import scipy.sparse
  import pytensor
  from pytensor import scalar
  from pytensor.graph.basic import Variable
  from pytensor.graph.type import HasDataType
  from pytensor.tensor.type import DenseTensorType, TensorType
label_desc: Use image node_id 1 for calling a global function with example usage: _is_sparse(x) and returns: isinstance