code: def CBA_calc(classes, table, TOP, P):
      """
      Calculate Class balance accuracy (CBA).
  
      :param classes: confusion matrix classes
      :type classes: list
      :param table: input confusion matrix
      :type table: dict
      :param TOP: number of positives in predict vector per class
      :type TOP: dict
      :param P: number of actual positives per class
      :type P: dict
      :return: CBA as float
      """
      try:
          result = 0
          class_number = len(classes)
          for i in classes:
              result += (table[i][i]) / (max(TOP[i], P[i]))
          return result / class_number
      except Exception:
          return "None"
  
imports: from __future__ import division
  import math
  import operator
  from functools import reduce
  from .pycm_interpret import *
  from .pycm_ci import kappa_SE_calc, CI_calc, SE_calc
  from .pycm_util import complement
label_desc: Use image node_id 11 for calling a global function with example usage: CBA_calc(classes, table, TOP, P) and returns: unknown, str