code: def build_next_level(
      features,
      labels,
      peaks,
      global_features,
      global_pred_labels,
      global_peaks,
  ):
      global_peak_to_label = global_pred_labels[global_peaks]
      global_label_to_peak = np.zeros_like(global_peak_to_label)
      for i, pl in enumerate(global_peak_to_label):
          global_label_to_peak[pl] = i
      cluster_ind = np.split(
          np.argsort(global_pred_labels),
          np.unique(np.sort(global_pred_labels), return_index=True)[1][
              1:
          ],
      )
      cluster_features = np.zeros(
          (len(peaks), global_features.shape[1])
      )
      for pi in range(len(peaks)):
          cluster_features[global_label_to_peak[pi], :] = np.mean(
              global_features[cluster_ind[pi], :], axis=0
          )
      features = features[peaks]
      labels = labels[peaks]
      return features, labels, cluster_features
  
file_path: dgl/examples/pytorch/hilander/utils/deduce.py
imports: import dgl
  import numpy
  import torch
  from sklearn import mixture
  from .density import density_to_peaks, density_to_peaks_vectorize
label_desc: Use image node_id 10 for calling a global function with example usage: build_next_level(features, labels, peaks, global_features, global_pred_labels, global_peaks) and returns: features,  labels,  cluster_features