code: def spdiags(data, diags, m, n, format=None):
      """
      Return a sparse matrix from diagonals.
  
      Parameters
      ----------
      data : array_like
          matrix diagonals stored row-wise
      diags : diagonals to set
          - k = 0  the main diagonal
          - k > 0  the k-th upper diagonal
          - k < 0  the k-th lower diagonal
      m, n : int
          shape of the result
      format : str, optional
          Format of the result. By default (format=None) an appropriate sparse
          matrix format is returned. This choice is subject to change.
  
      See Also
      --------
      diags : more convenient form of this function
      dia_matrix : the sparse DIAgonal format.
  
      Examples
      --------
      >>> from scipy.sparse import spdiags
      >>> data = np.array([[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]])
      >>> diags = np.array([0, -1, 2])
      >>> spdiags(data, diags, 4, 4).toarray()
      array([[1, 0, 3, 0],
             [1, 2, 0, 4],
             [0, 2, 3, 0],
             [0, 0, 3, 4]])
  
      """
      return dia_matrix((data, diags), shape=(m, n)).asformat(format)
  
imports: import numbers
  from functools import partial
  import numpy
  from scipy._lib._util import check_random_state, rng_integers
  from .sputils import upcast, get_index_dtype, isscalarlike
  from .csr import csr_matrix
  from .csc import csc_matrix
  from .bsr import bsr_matrix
  from .coo import coo_matrix
  from .dia import dia_matrix
  from .base import issparse
label_desc: Use image node_id 1 for calling a global function with example usage: spdiags(data, diags, m, n, format) and returns: dia_matrix