code: def get_unique_pairs(n_bundle, pairs=None):
      """Make unique pairs from n_bundle bundles.
  
      The function allows to input a previous pairs assignment so that the new
      pairs are different.
  
      Parameters
      ----------
      n_bundle : int
          Number of bundles to be matched in pairs.
  
      pairs : array, optional
          array containing the indexes of previous pairs.
      """
      if not isinstance(n_bundle, int):
          raise TypeError(
              f"n_bundle must be an int but is a {type(n_bundle)}"
          )
  
      if n_bundle <= 1:
          raise ValueError(f"n_bundle must be > 1 but is {n_bundle}")
  
      # Generate indexes
      index = np.arange(n_bundle)
      n_pair = n_bundle // 2
  
      # If n_bundle is odd, we exclude one ensuring it wasn't previously excluded
      excluded = None
      if np.mod(n_bundle, 2) == 1:
          if pairs is None:
              excluded = np.random.choice(index)
          else:
              excluded = np.random.choice(np.unique(pairs))
  
          index = index[index != excluded]
  
      # Shuffle indexes
      index = np.random.permutation(index)
      new_pairs = index.reshape((n_pair, 2))
  
      if pairs is None or n_bundle <= 3:
          return new_pairs, excluded
  
      # Repeat the shuffle process until we find new unique pairs
      all_pairs = np.vstack(
          (new_pairs, new_pairs[:, ::-1], pairs, pairs[:, ::-1])
      )
  
      while len(np.unique(all_pairs, axis=0)) < 4 * n_pair:
          index = np.random.permutation(index)
          new_pairs = index.reshape((n_pair, 2))
          all_pairs = np.vstack(
              (new_pairs, new_pairs[:, ::-1], pairs, pairs[:, ::-1])
          )
  
      return new_pairs, excluded
  
imports: import logging
  import abc
  from itertools import combinations
  import numpy
  from dipy.core.optimize import Optimizer
  from dipy.align.bundlemin import _bundle_minimum_distance, _bundle_minimum_distance_asymmetric, distance_matrix_mdf
  from dipy.tracking.streamline import transform_streamlines, unlist_streamlines, center_streamlines, set_number_of_points, select_random_set_of_streamlines, length, Streamlines
  from dipy.segment.clustering import qbx_and_merge
  from dipy.core.geometry import compose_transformations, compose_matrix, decompose_matrix
  from time import time
label_desc: Use image node_id 9 for calling a global function with example usage: get_unique_pairs(n_bundle, pairs) and returns: new_pairs,  excluded, new_pairs,  excluded