code: def PC_AC1_calc(P, TOP, POP):
      """
      Calculate Percent chance agreement for Gwet's AC1.
  
      :param P: number of actual positives per class
      :type P: dict
      :param TOP: number of positives in predict vector per class
      :type TOP: dict
      :param POP: population or total number of samples per class
      :type POP:dict
      :return: percent chance agreement as float
      """
      try:
          result = 0
          classes = list(P.keys())
          for i in classes:
              pi = (P[i] + TOP[i]) / (2 * POP[i])
              result += pi * (1 - pi)
          result = result / (len(classes) - 1)
          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 38 for calling a global function with example usage: PC_AC1_calc(P, TOP, POP) and returns: result, str