code: def read_sparse_matrix(
      filepath: types.PathLike,
      *,
      kind: str = "csc",
  ) -> sp.csc_matrix | sp.csr_matrix:
      """
      Read the data, indices, indptr, and shape arrays from a ``.npz`` file on disk
      at ``filepath``, and return an instantiated sparse matrix.
  
      Args:
          filepath: Path to file on disk from which data will be read.
          kind ({'csc', 'csr'}): Kind of sparse matrix to instantiate.
  
      Returns:
          An instantiated sparse matrix, whose type depends on the value of ``kind``.
  
      See Also:
          https://docs.scipy.org/doc/numpy-1.13.0/reference/routines.io.html#numpy-binary-files-npy-npz
      """
      npz_file = np.load(filepath)
      if kind == "csc":
          return sp.csc_matrix(
              (
                  npz_file["data"],
                  npz_file["indices"],
                  npz_file["indptr"],
              ),
              shape=npz_file["shape"],
          )
      elif kind == "csr":
          return sp.csr_matrix(
              (
                  npz_file["data"],
                  npz_file["indices"],
                  npz_file["indptr"],
              ),
              shape=npz_file["shape"],
          )
      else:
          raise ValueError(
              errors.value_invalid_msg("kind", kind, {"csc", "csr"})
          )
  
imports: from __future__ import annotations
  from typing import Union
  import numpy
  import scipy.sparse
  from ..None import errors, types, utils
  from .None import utils
label_desc: Use image node_id 1 for calling a global function with example usage: read_sparse_matrix(filepath) and returns: sp, sp