code: def _sparse_series_to_coo(
      ss, row_levels=(0,), column_levels=(1,), sort_labels=False
  ):
      """Convert a SparseSeries to a scipy.sparse.coo_matrix using index
      levels row_levels, column_levels as the row and column
      labels respectively. Returns the sparse_matrix, row and column labels.
      """
  
      import scipy.sparse
  
      if ss.index.nlevels < 2:
          raise ValueError(
              "to_coo requires MultiIndex with nlevels > 2"
          )
      if not ss.index.is_unique:
          raise ValueError(
              "Duplicate index entries are not allowed in to_coo "
              "transformation."
          )
  
      # to keep things simple, only rely on integer indexing (not labels)
      row_levels = [ss.index._get_level_number(x) for x in row_levels]
      column_levels = [
          ss.index._get_level_number(x) for x in column_levels
      ]
  
      v, i, j, rows, columns = _to_ijv(
          ss,
          row_levels=row_levels,
          column_levels=column_levels,
          sort_labels=sort_labels,
      )
      sparse_matrix = scipy.sparse.coo_matrix(
          (v, (i, j)), shape=(len(rows), len(columns))
      )
      return sparse_matrix, rows, columns
  
imports: from pandas.compat import OrderedDict, lmap
  from pandas.core.index import Index, MultiIndex
  from pandas.core.series import Series
label_desc: Use image node_id 3 for calling a global function with example usage: _sparse_series_to_coo(ss, row_levels, column_levels, sort_labels) and returns: sparse_matrix,  rows,  columns