code: def test_cluster_centroids_hard_target_class():
      # check that the samples selecting by the hard voting corresponds to the
      # targeted class
      # non-regression test for:
      # https://github.com/scikit-learn-contrib/imbalanced-learn/issues/738
      X, y = make_classification(
          n_samples=1000,
          n_features=2,
          n_informative=1,
          n_redundant=0,
          n_repeated=0,
          n_clusters_per_class=1,
          weights=[0.3, 0.7],
          class_sep=0.01,
          random_state=0,
      )
  
      cc = ClusterCentroids(voting="hard", random_state=0)
      X_res, y_res = cc.fit_resample(X, y)
  
      minority_class_indices = np.flatnonzero(y == 0)
      X_minority_class = X[minority_class_indices]
  
      resampled_majority_class_indices = np.flatnonzero(y_res == 1)
      X_res_majority = X_res[resampled_majority_class_indices]
  
      sample_from_minority_in_majority = [
          np.all(np.isclose(selected_sample, minority_sample))
          for selected_sample in X_res_majority
          for minority_sample in X_minority_class
      ]
      assert sum(sample_from_minority_in_majority) == 0
  
file_path: imbalanced-learn/imblearn/under_sampling/_prototype_generation/tests/test_cluster_centroids.py
imports: from collections import Counter
  import numpy
  import pytest
  from scipy import sparse
  from sklearn.cluster import KMeans
  from sklearn.datasets import make_classification
  from sklearn.linear_model import LogisticRegression
  from imblearn.under_sampling import ClusterCentroids
  from imblearn.utils.testing import _CustomClusterer
label_desc: Use image node_id 7 for calling a global function with example usage: test_cluster_centroids_hard_target_class() without return types