code: def select_epsilon_leaf(condensed_tree, n_clusters):
      """
      Select epsilon so that the leaves of condensed tree,
          after truncating at the above epsilon,
          has exactly 'n_clusters' clusters
      """
      # Use an epsilon value that produces the right number of clusters.
      # The condensed tree of HDBSCAN has this information.
      # Extract the lambda levels (=1/distance) from the condensed tree
      lambdas = condensed_tree._raw_tree["lambda_val"]
      # We don't want values that produce a large cluster and
      #   just one or two individual points.
      child_sizes = condensed_tree._raw_tree["child_size"]
      child_sizes = child_sizes.astype(int)
      # Keep only those lambda values corresponding to cluster separation;
      #   i.e., with child_sizes > 1
      lambdas = lambdas[child_sizes > 1]
      # Get the unique values, because when two clusters fall out of one,
      #   the entry with lambda is repeated.
      lambdas = np.unique(lambdas.astype(float))
      if n_clusters > len(lambdas) + 1:
          warn(
              f"HDBSCAN can only compute {len(lambdas)+1} clusters. "
              f"Setting n_clusters to {len(lambdas)+1}..."
          )
          n_clusters = len(lambdas) + 1
  
      # lambda values are sorted by np.unique.
      # Now, get epsilon (distance threshold) as 1/lambda
      epsilon = 1.0 / lambdas[n_clusters - 2]
      # At this epsilon, n_clusters have been split.
      # Stop splits at epsilons smaller than this.
      # To allow for numerical errors,
      return epsilon - 1.0e-12
  
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 7 for calling a global function with example usage: select_epsilon_leaf(condensed_tree, n_clusters) and returns: unknown