code: def ARI_calc(classes, table, TOP, P, POP):
      """
      Calculate Adjusted Rand index (ARI).
  
      :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
      :param POP: population or total number of samples
      :type POP: int
      :return: ARI as float
      """
      try:
          table_sum = 0
          TOP_sum = 0
          P_sum = 0
          nc2 = ncr(POP, 2)
          for i in classes:
              TOP_sum += ncr(TOP[i], 2)
              P_sum += ncr(P[i], 2)
              for j in classes:
                  table_sum += ncr(table[i][j], 2)
          x = (TOP_sum * P_sum) / nc2
          ARI = (table_sum - x) / ((P_sum + TOP_sum) / 2 - x)
          return ARI
      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 7 for calling a global function with example usage: ARI_calc(classes, table, TOP, P, POP) and returns: ARI, str