code: def predict(self, X):
          
  
          dists = cdist(X, self.landmarks_, self.metric)
          pfunc_name = self.ward_predictor if self.linkage == 'ward' else self.linkage
  
          try:
              pooling_func = POOLING_FUNCTIONS[pfunc_name]
          except KeyError:
                  raise ValueError("linkage {} is not supported".format(pfunc_name))
  
          pooled_distances = np.empty(len(X))
          pooled_distances.fill(np.infty)
          labels = np.zeros(len(X), dtype=int)
  
          for i in range(self.n_clusters):
              if np.any(self.landmark_labels_ == i):
                  d = pooling_func(dists[:, self.landmark_labels_ == i],
                                   self.cardinality_[i],
                                   self.squared_distances_within_cluster_[i])
                  if np.any(d < 0):
                      warnings.warn("Distance shouldn't be negative.")
                  mask = (d < pooled_distances)
                  pooled_distances[mask] = d[mask]
                  labels[mask] = i
              else:
                  print("No data points were assigned to cluster {}".format(i))
  
          return labels
docs: Predict the closest cluster each sample in X belongs to.
  
          Parameters
          ----------
          X : {array-like, sparse matrix}, shape = [n_samples, n_features]
              New data to predict.
  
          Returns
          -------
          labels : array, shape [n_samples,]
              Index of the cluster each sample belongs to.