code: def kdn_score(X, y, k):
      """
      Calculates the K-Disagreeing Neighbors score (KDN) of each sample in the
      input dataset.
  
      Parameters
      ----------
      X : array of shape (n_samples, n_features)
          The input data.
  
      y : array of shape (n_samples)
          class labels of each example in X.
  
      k : int
          Neighborhood size for calculating the KDN score.
  
      Returns
      -------
  
      score : array of shape = [n_samples,1]
          KDN score of each sample in X.
  
      neighbors : array of shape = [n_samples,k]
          Indexes of the k neighbors of each sample in X.
  
  
      References
      ----------
      M. R. Smith, T. Martinez, C. Giraud-Carrier, An instance level analysis of
      data complexity,
      Machine Learning 95 (2) (2014) 225-256.
  
      """
  
      nbrs = NearestNeighbors(
          n_neighbors=k + 1, algorithm="kd_tree"
      ).fit(X)
      _, indices = nbrs.kneighbors(X)
      neighbors = indices[:, 1:]
      diff_class = np.tile(y, (k, 1)).transpose() != y[neighbors]
      score = np.sum(diff_class, axis=1) / k
      return score, neighbors
  
imports: import numpy
  from scipy.stats import mode
  from sklearn.neighbors import NearestNeighbors
label_desc: Use image node_id 2 for calling a global function with example usage: kdn_score(X, y, k) and returns: score,  neighbors