code: def list_to_csr(label_list, shape, dtype=np.int64):
      """Converts the given list of lists of labels into a sparse matrix.
  
      Parameter
      ---------
      label_list : list of list of int
          List of lists of labels.
      shape : tuple
          Target matrix shape.
  
      Returns
      -------
      result : scipy.sparse.csr_matrix
          A sparse matrix of the given input.
      """
      if np.all(np.array([len(item) for item in label_list]) == 0):
          return csr_matrix(shape, dtype=dtype)
  
      col_ind = [
          item if len(item) > 0 else np.empty(0, dtype=np.int64)
          for item in label_list
      ]
  
      col_ind = np.concatenate(col_ind, dtype=np.int64)
      row_ind = np.concatenate(
          [
              [i] * len(item)
              for i, item in enumerate(label_list)
              if len(item)
          ],
          dtype=np.int64,
      )
      data = np.ones_like(col_ind, dtype=np.int64)
  
      return csr_matrix(
          (data, (row_ind, col_ind)), shape=shape, dtype=dtype
      )
  
file_path: small-text/small_text/utils/labels.py
imports: import numpy
  from scipy.sparse import csr_matrix
  from scipy.sparse import vstack
  from small_text.base import LABEL_UNLABELED
  from small_text.utils.annotations import deprecated
label_desc: Use image node_id 6 for calling a global function with example usage: list_to_csr(label_list, shape, dtype) and returns: csr_matrix, csr_matrix