code: def remap_single_linkage_tree(tree, internal_to_raw, outliers):
      """
      Takes an internal single_linkage_tree structure and adds back in a set of points
      that were initially detected as non-finite and returns that new tree.
      These points will all be merged into the final node at np.inf distance and
      considered noise points.
  
      Parameters
      ----------
      tree: single_linkage_tree
      internal_to_raw: dict
          a mapping from internal integer index to the raw integer index
      finite_index: ndarray
          Boolean array of which entries in the raw data were finite
      """
      finite_count = len(internal_to_raw)
  
      outlier_count = len(outliers)
      for i, (left, right, distance, size) in enumerate(tree):
          if left < finite_count:
              tree[i, 0] = internal_to_raw[left]
          else:
              tree[i, 0] = left + outlier_count
          if right < finite_count:
              tree[i, 1] = internal_to_raw[right]
          else:
              tree[i, 1] = right + outlier_count
  
      outlier_tree = np.zeros((len(outliers), 4))
      last_cluster_id = tree[tree.shape[0] - 1][0:2].max()
      last_cluster_size = tree[tree.shape[0] - 1][3]
      for i, outlier in enumerate(outliers):
          outlier_tree[i] = (
              outlier,
              last_cluster_id + 1,
              np.inf,
              last_cluster_size + 1,
          )
          last_cluster_id += 1
          last_cluster_size += 1
      tree = np.vstack([tree, outlier_tree])
      return 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 10 for calling a global function with example usage: remap_single_linkage_tree(tree, internal_to_raw, outliers) and returns: tree