code: def cluster_bundle(
      bundle, clust_thr, rng, nb_pts=20, select_randomly=500000
  ):
      """Clusters bundles
  
      Parameters
      ----------
      bundle : Streamlines
          White matter tract
      clust_thr : float
          clustering threshold used in quickbundlesX
      rng : np.random.Generator
          numpy's random generator for generating random values.
      nb_pts: integer (default 20)
          Discretizing streamlines to have nb_points number of points
      select_randomly: integer (default 500000)
          Randomly select streamlines from the input bundle
  
      Returns
      -------
      centroids : Streamlines
          clustered centroids of the input bundle
  
      References
      ----------
      .. [Garyfallidis12] Garyfallidis E. et al., QuickBundles a method for
                          tractography simplification, Frontiers in Neuroscience,
                          vol 6, no 175, 2012.
      """
  
      model_cluster_map = qbx_and_merge(
          bundle,
          clust_thr,
          nb_pts=nb_pts,
          select_randomly=select_randomly,
          rng=rng,
      )
      centroids = model_cluster_map.centroids
  
      return centroids
  
imports: from time import time
  from itertools import chain
  import logging
  import numpy
  from dipy.tracking.streamline import set_number_of_points, nbytes, select_random_set_of_streamlines
  from dipy.segment.clustering import qbx_and_merge
  from dipy.tracking.distances import bundles_distances_mdf, bundles_distances_mam
  from dipy.align.streamlinear import StreamlineLinearRegistration, BundleMinDistanceMetric, BundleSumDistanceMatrixMetric, BundleMinDistanceAsymmetricMetric
  from dipy.tracking.streamline import Streamlines, length
  from dipy.utils.deprecator import deprecated_params
  from nibabel.affines import apply_affine
label_desc: Use image node_id 4 for calling a global function with example usage: cluster_bundle(bundle, clust_thr, rng, nb_pts, select_randomly) and returns: centroids