code: def test_cluster_centroids_custom_clusterer():
      clusterer = _CustomClusterer()
      cc = ClusterCentroids(estimator=clusterer, random_state=RND_SEED)
      cc.fit_resample(X, Y)
      assert isinstance(cc.estimator_.cluster_centers_, np.ndarray)
  
      clusterer = _CustomClusterer(expose_cluster_centers=False)
      cc = ClusterCentroids(estimator=clusterer, random_state=RND_SEED)
      err_msg = (
          "`estimator` should be a clustering estimator exposing a fitted parameter "
          "`cluster_centers_`."
      )
      with pytest.raises(RuntimeError, match=err_msg):
          cc.fit_resample(X, Y)
  
      clusterer = LogisticRegression()
      cc = ClusterCentroids(estimator=clusterer, random_state=RND_SEED)
      err_msg = (
          "`estimator` should be a clustering estimator exposing a parameter "
          "`n_clusters` and a fitted parameter `cluster_centers_`."
      )
      with pytest.raises(ValueError, match=err_msg):
          cc.fit_resample(X, Y)
  
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 8 for calling a global function with example usage: test_cluster_centroids_custom_clusterer() without return types