code: def test_switch_to_leaf():
      """
      Verify that when we request more clusters than 'eom' can handle,
          method switches to 'leaf' and the results match 'leaf'.
      """
      # Given the max number of clusters that can be produced by 'eom',
      #   (these are produced for epsilon=0) (??? Needs verification)
      clusterer = HDBSCAN(
          cluster_selection_method="eom", cluster_selection_epsilon=0
      ).fit(X)
      max_clusters = n_clusters_from_labels(clusterer.labels_)
  
      with warnings.catch_warnings(record=True) as w:
          # When we try flat clustering with 'eom' method for more n_clusters,
          clusterer_flat = HDBSCAN_flat(
              X,
              cluster_selection_method="eom",
              n_clusters=max_clusters + 2,
          )
          # Then, a warning is raised saying 'eom' can't get this clustering,
          assert len(w) > 0
          assert issubclass(w[-1].category, UserWarning) or issubclass(
              w[-1].category, DeprecationWarning
          )
          # assert "Cannot predict" in str(w[-1].message)
  
      # the resulting clusterer switches to using method 'leaf',
      assert (
          clusterer_flat.cluster_selection_method == "leaf"
      ), "cluster selection method has not switched to 'leaf'"
      # and the resulting probabilities and labels must match
      epsilon = clusterer_flat.cluster_selection_epsilon
      clusterer_leaf = HDBSCAN(
          cluster_selection_method="leaf",
          cluster_selection_epsilon=epsilon,
      ).fit(X)
      assert_array_equal(clusterer_flat.labels_, clusterer_leaf.labels_)
      assert_array_equal(
          clusterer_flat.probabilities_, clusterer_leaf.probabilities_
      )
      return
  
file_path: hdbscan/hdbscan/tests/test_flat.py
imports: import warnings
  import numpy
  from hdbscan import HDBSCAN, approximate_predict
  from hdbscan.flat import HDBSCAN_flat, approximate_predict_flat, membership_vector_flat, all_points_membership_vectors_flat
  from sklearn.datasets import make_blobs, make_moons
  from sklearn.preprocessing import StandardScaler
  from sklearn.model_selection import train_test_split
  from sklearn.utils._testing import assert_array_equal, assert_array_less
label_desc: Use image node_id 4 for calling a global function with example usage: test_switch_to_leaf() without return types