code: def _tree_to_labels(
      X,
      single_linkage_tree,
      min_cluster_size=10,
      cluster_selection_method="eom",
      allow_single_cluster=False,
      match_reference_implementation=False,
      cluster_selection_epsilon=0.0,
      max_cluster_size=0,
  ):
      """Converts a pretrained tree and cluster size into a
      set of labels and probabilities.
      """
      condensed_tree = condense_tree(
          single_linkage_tree, min_cluster_size
      )
      stability_dict = compute_stability(condensed_tree)
      labels, probabilities, stabilities = get_clusters(
          condensed_tree,
          stability_dict,
          cluster_selection_method,
          allow_single_cluster,
          match_reference_implementation,
          cluster_selection_epsilon,
          max_cluster_size,
      )
  
      return (
          labels,
          probabilities,
          stabilities,
          condensed_tree,
          single_linkage_tree,
      )
  
imports: import numpy
  from sklearn.base import BaseEstimator, ClusterMixin
  from sklearn.metrics import pairwise_distances
  from scipy.sparse import issparse
  from sklearn.neighbors import KDTree, BallTree
  from joblib import Memory
  from warnings import warn
  from sklearn.utils import check_array
  from joblib.parallel import cpu_count
  from scipy.sparse import csgraph
  from ._hdbscan_linkage import single_linkage, mst_linkage_core, mst_linkage_core_vector, label
  from ._hdbscan_tree import condense_tree, compute_stability, get_clusters, outlier_scores
  from ._hdbscan_reachability import mutual_reachability, sparse_mutual_reachability
  from ._hdbscan_boruvka import KDTreeBoruvkaAlgorithm, BallTreeBoruvkaAlgorithm
  from .dist_metrics import DistanceMetric
  from .plots import CondensedTree, SingleLinkageTree, MinimumSpanningTree
  from .prediction import PredictionData
  from numpy import isclose
label_desc: Use image node_id 1 for calling a global function with example usage: _tree_to_labels(X, single_linkage_tree, min_cluster_size, cluster_selection_method, allow_single_cluster, match_reference_implementation, cluster_selection_epsilon, max_cluster_size) and returns: labels,  probabilities,  stabilities,  condensed_tree,  single_linkage_tree