code: def _rsl_boruvka_kdtree(
      X,
      k=5,
      alpha=1.0,
      metric="euclidean",
      leaf_size=40,
      core_dist_n_jobs=4,
      **kwargs,
  ):
      if core_dist_n_jobs < 1:
          core_dist_n_jobs = max(cpu_count() + 1 + core_dist_n_jobs, 1)
  
      dim = X.shape[0]
      min_samples = min(dim - 1, k)
  
      tree = KDTree(X, metric=metric, leaf_size=leaf_size, **kwargs)
      alg = KDTreeBoruvkaAlgorithm(
          tree,
          min_samples,
          metric=metric,
          alpha=alpha,
          leaf_size=leaf_size,
          **kwargs,
      )
      min_spanning_tree = alg.spanning_tree()
  
      single_linkage_tree = label(min_spanning_tree)
      single_linkage_tree = SingleLinkageTree(single_linkage_tree)
  
      return single_linkage_tree
  
imports: import numpy
  from sklearn.base import BaseEstimator, ClusterMixin
  from sklearn.metrics import pairwise_distances
  from scipy.sparse import issparse
  from joblib import Memory
  from sklearn.utils import check_array
  from ._hdbscan_linkage import mst_linkage_core, mst_linkage_core_vector, label
  from ._hdbscan_boruvka import KDTreeBoruvkaAlgorithm, BallTreeBoruvkaAlgorithm
  from .dist_metrics import DistanceMetric
  from ._hdbscan_reachability import mutual_reachability
  from .plots import SingleLinkageTree
  from sklearn.neighbors import KDTree, BallTree
  from warnings import warn
label_desc: Use image node_id 4 for calling a global function with example usage: _rsl_boruvka_kdtree(X, k, alpha, metric, leaf_size, core_dist_n_jobs) and returns: single_linkage_tree