code: def matrix_params_from_table(table, classes=None, transpose=False):
      """
      Calculate TP, TN, FP, and FN from the input confusion matrix.
  
      :param table: input confusion matrix
      :type table: dict
      :param classes: ordered labels of classes
      :type classes: list
      :param transpose: transpose flag
      :type transpose: bool
      :return: [classes_list, table, TP, TN, FP, FN]
      """
      if classes is None:
          classes = sorted(table.keys())
      classes_set = set(classes)
      if len(classes_set) < 2:
          raise pycmMatrixError(CLASS_NUMBER_ERROR)
      if classes_set > set(table.keys()):
          raise pycmMatrixError(CLASSES_ERROR)
      table_temp = table
      map_dict = {k: 0 for k in classes}
      TP_dict = map_dict.copy()
      TN_dict = map_dict.copy()
      FP_dict = map_dict.copy()
      FN_dict = map_dict.copy()
      for i in classes:
          TP_dict[i] = table[i][i]
          sum_row = sum(list(table[i].values()))
          for j in classes:
              if j != i:
                  FN_dict[i] += table[i][j]
                  FP_dict[j] += table[i][j]
                  TN_dict[j] += sum_row - table[i][j]
      if transpose:
          temp = FN_dict
          FN_dict = FP_dict
          FP_dict = temp
          table_temp = transpose_func(classes, table)
      return [classes, table_temp, TP_dict, TN_dict, FP_dict, FN_dict]
  
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 15 for calling a global function with example usage: matrix_params_from_table(table, classes, transpose) and returns: list