code: def sparse_matrix_calc(classes, table):
      """
      Return sparse confusion matrix and its classes.
  
      :param classes: confusion matrix classes
      :type classes: list
      :param table: input confusion matrix
      :type table: dict
      :return: a list containing 3 dicts [sparse_table, actual_classes, predict_classes]
      """
      sparse_table = {}
      for key in table:
          sparse_table[key] = table[key].copy()
      predict_classes = classes.copy()
      actual_classes = classes.copy()
      for x in classes:
          row_sum = 0
          col_sum = 0
          for y in classes:
              row_sum += table[x][y]
              col_sum += table[y][x]
          if row_sum == 0:
              del sparse_table[x]
              actual_classes.remove(x)
          if col_sum == 0:
              for row in actual_classes:
                  del sparse_table[row][x]
              predict_classes.remove(x)
      return [sparse_table, actual_classes, predict_classes]
  
imports: from __future__ import division
  import sys
  import math
  import numpy
  import re
  from .pycm_param import *
  from .pycm_error import pycmMatrixError
  from warnings import warn
  from functools import wraps
label_desc: Use image node_id 13 for calling a global function with example usage: sparse_matrix_calc(classes, table) and returns: list