code: def QuadWeightedKappa(y, y_pred):
      y_pred = np.argmax(y_pred, 1)
      cm = confusion_matrix(y, y_pred)
      classes_y, counts_y = np.unique(y, return_counts=True)
      classes_y_pred, counts_y_pred = np.unique(
          y_pred, return_counts=True
      )
      E = np.zeros((classes_y.shape[0], classes_y.shape[0]))
      for i, c1 in enumerate(classes_y):
          for j, c2 in enumerate(classes_y_pred):
              E[c1, c2] = counts_y[i] * counts_y_pred[j]
      E = E / np.sum(E) * np.sum(cm)
      w = np.zeros((classes_y.shape[0], classes_y.shape[0]))
      for i in range(classes_y.shape[0]):
          for j in range(classes_y.shape[0]):
              w[i, j] = (
                  float((i - j) ** 2) / (classes_y.shape[0] - 1) ** 2
              )
      re = 1 - np.sum(w * cm) / np.sum(w * E)
      return re
  
imports: import numpy
  import tensorflow
  from deepchem.data import NumpyDataset, pad_features
  from deepchem.metrics import to_one_hot
  from deepchem.models.tensorgraph.layers import Layer, Dense, SoftMax, Reshape, SparseSoftMaxCrossEntropy, BatchNorm, Conv2D, MaxPool2D, WeightedError, Dropout, ReLU, Stack, Flatten, ReduceMax, WeightDecay
  from deepchem.models.tensorgraph.layers import L2Loss, Label, Weights, Feature
  from deepchem.models.tensorgraph.tensor_graph import TensorGraph
  from deepchem.trans import undo_transforms
  from deepchem.data.data_loader import ImageLoader
  from sklearn.metrics import confusion_matrix, accuracy_score
label_desc: Use image node_id 5 for calling a global function with example usage: QuadWeightedKappa(y, y_pred) and returns: re