code: def weighted_alpha_calc(classes, table, P, TOP, POP, weight):
      """
      Calculate Weighted Krippendorff's alpha.
  
      :param classes: confusion matrix classes
      :type classes: list
      :param table: input confusion matrix
      :type table: dict
      :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
      :param weight: weight matrix
      :type weight: dict
      :return: weighted alpha as float
      """
      p_e = 0
      p_a = 0
      population = list(POP.values())[0]
      epsi = 1 / (2 * population)
      try:
          w_max = max(map(lambda x: max(x.values()), weight.values()))
          for i in classes:
              for j in classes:
                  v_i_j = 1 - weight[i][j] / w_max
                  p_e += (((P[i] + TOP[j]) / (POP[i] * 2)) ** 2) * v_i_j
                  p_a += table[i][j] * v_i_j / POP[i]
          p_a = (1 - epsi) * p_a + epsi
          weighted_alpha = reliability_calc(p_e, p_a)
          return weighted_alpha
      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 5 for calling a global function with example usage: weighted_alpha_calc(classes, table, P, TOP, POP, weight) and returns: weighted_alpha, str