code: def lambda_B_calc(classes, table, TOP, POP):
      """
      Calculate Goodman and Kruskal's lambda B.
  
      :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 POP: population or total number of samples
      :type POP: int
      :return: Goodman and Kruskal's lambda B as float
      """
      try:
          result = 0
          length = POP
          maxresponse = max(list(TOP.values()))
          for i in classes:
              result += max(list(table[i].values()))
          result = (result - maxresponse) / (length - maxresponse)
          return result
      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 29 for calling a global function with example usage: lambda_B_calc(classes, table, TOP, POP) and returns: result, str