code: def _from_spmatrix(spmatrix, dtype=None, chunk_size=None, gpu=None):
      if gpu is None:
          m = get_array_module(spmatrix)
          if cp is not None and m is cp:
              gpu = True
          elif cp is np:
              gpu = False
      if dtype and spmatrix.dtype != dtype:
          spmatrix = spmatrix.astype(dtype)
      spmatrix = spmatrix.tocsr()
      op = CSRMatrixDataSource(
          indices=spmatrix.indices,
          indptr=spmatrix.indptr,
          data=spmatrix.data,
          shape=spmatrix.shape,
          dtype=spmatrix.dtype,
          gpu=gpu,
          chunk_size=chunk_size,
      )
      return op(spmatrix.shape, chunk_size=chunk_size)
  
imports: import numpy
  from ...None import opcodes
  from ...lib.sparse.core import issparse, get_array_module, cp, cps, sps
  from ...lib.sparse import SparseNDArray
  from ...serialization.serializables import FieldTypes, AnyField, NDArrayField, TupleField
  from ...utils import on_serialize_shape, on_deserialize_shape
  from ..core import TENSOR_TYPE, TensorOrder, TensorData, Tensor
  from ..utils import get_chunk_slices
  from ..array_utils import array_module, is_array, is_cupy
  from .core import TensorNoInput
  from .scalar import scalar
label_desc: Use image node_id 1 for calling a global function with example usage: _from_spmatrix(spmatrix, dtype, chunk_size, gpu) and returns: op