code: def kappa(intersect_area, pred_area, label_area):
      """
      Calculate kappa coefficient
  
      Args:
          intersect_area (Tensor): The intersection area of prediction and ground truth on all classes..
          pred_area (Tensor): The prediction area on all classes.
          label_area (Tensor): The ground truth area on all classes.
  
      Returns:
          float: kappa coefficient.
      """
      intersect_area = intersect_area.numpy().astype(np.float64)
      pred_area = pred_area.numpy().astype(np.float64)
      label_area = label_area.numpy().astype(np.float64)
      total_area = np.sum(label_area)
      po = np.sum(intersect_area) / total_area
      pe = np.sum(pred_area * label_area) / (total_area * total_area)
      kappa = (po - pe) / (1 - pe)
      return kappa
  
file_path: PaddleSeg/paddleseg/utils/metrics.py
imports: import numpy
  import paddle
  import paddle.nn.functional
  import sklearn.metrics
label_desc: Use image node_id 7 for calling a global function with example usage: kappa(intersect_area, pred_area, label_area) and returns: kappa