code: def select_epsilon_eom(condensed_tree, n_clusters):
      """
      Select epsilon so that persistence-based clustering,
          after truncating the tree at the above epsilon,
          has exactly 'n_clusters' clusters
      """
      # With method 'eom', max clusters are produced for epsilon=0,
      #   as computed by
      eom_base_clusters = condensed_tree._select_clusters()
      max_clusters = len(eom_base_clusters)
      # Increasing epsilon can only reduce the number of ouput clusters.
  
      assert n_clusters <= max_clusters, (
          f"Cannot produce more than {max_clusters} with method 'eom'. "
          + "Use method 'leaf' instead to extract flat clustering."
      )
  
      tree = condensed_tree._raw_tree
      # To select epsilon, consider all values where clusters are split
      cluster_lambdas = tree["lambda_val"][tree["child_size"] > 1]
      candidate_epsilons = 1.0 / np.unique(cluster_lambdas) - 1.0e-12
      # Subtract the extra e-12 to avoid numerical errors in comparison
      # Then, we avoid splitting for all epsilon below this.
      candidate_epsilons = np.sort(candidate_epsilons)[::-1]
  
      for epsilon in candidate_epsilons:
          sel_clusters = _new_select_clusters(condensed_tree, epsilon)
          if len(sel_clusters) == n_clusters:
              break
      else:
          raise RuntimeError("Could not find epsilon")
  
      return epsilon
  
imports: import copy
  from warnings import warn
  import numpy
  from ._hdbscan_tree import compute_stability, get_cluster_tree_leaves
  from .hdbscan_ import HDBSCAN, _tree_to_labels
  from .plots import _bfs_from_cluster_tree
  from .prediction import PredictionData, _find_cluster_and_probability, _find_neighbor_and_lambda
  from ._prediction_utils import get_tree_row_with_child, dist_membership_vector, outlier_membership_vector, prob_in_some_cluster, all_points_dist_membership_vector, all_points_outlier_membership_vector, all_points_prob_in_some_cluster
label_desc: Use image node_id 6 for calling a global function with example usage: select_epsilon_eom(condensed_tree, n_clusters) and returns: epsilon