code: def weighted_kappa_loss_np(
      y_true, y_pred, weightage="quadratic", eps=1e-6
  ):
      num_samples, num_classes = y_true.shape
      cat_labels = y_true.argmax(axis=1).reshape((-1, 1))
      label_mat = np.tile(cat_labels, (1, num_classes))
      row_label_vec = np.arange(num_classes).reshape((1, num_classes))
      label_mat_ = np.tile(row_label_vec, (num_samples, 1))
      if weightage == "linear":
          weight = np.abs(label_mat - label_mat_)
      else:
          weight = (label_mat - label_mat_) ** 2
      numerator = (y_pred * weight).sum()
      label_dist = y_true.sum(axis=0, keepdims=True)
      pred_dist = y_pred.sum(axis=0, keepdims=True)
  
      col_label_vec = row_label_vec.T
      row_mat = np.tile(row_label_vec, (num_classes, 1))
      col_mat = np.tile(col_label_vec, (1, num_classes))
      if weightage == "quadratic":
          weight_ = (col_mat - row_mat) ** 2
      else:
          weight_ = np.abs(col_mat - row_mat)
      weighted_pred_dist = np.matmul(weight_, pred_dist.T)
      denominator = np.matmul(label_dist, weighted_pred_dist).sum()
      denominator /= num_samples
      return np.log(np.nan_to_num(numerator / denominator) + eps)
  
file_path: addons/tensorflow_addons/losses/tests/kappa_loss_test.py
imports: import pytest
  import numpy
  import tensorflow
  from tensorflow_addons.losses.kappa_loss import WeightedKappaLoss
label_desc: Use image node_id 1 for calling a global function with example usage: weighted_kappa_loss_np(y_true, y_pred, weightage, eps) and returns: np