code: def _orient_by_roi_list(out, roi1, roi2):
      """
      Helper function to `orient_by_rois`
  
      Performs the inner loop separately. This is needed, because functions with
      `yield` always return a generator.
  
      Flips the streamlines in place (as needed) and returns a reference to the
      updated list.
      """
      for idx, sl in enumerate(out):
          dist1 = cdist(sl, roi1, "euclidean")
          dist2 = cdist(sl, roi2, "euclidean")
          min1 = np.argmin(dist1, 0)
          min2 = np.argmin(dist2, 0)
          if min1[0] > min2[0]:
              out[idx][:, 0] = sl[::-1][:, 0]
              out[idx][:, 1] = sl[::-1][:, 1]
              out[idx][:, 2] = sl[::-1][:, 2]
      return out
  
imports: from copy import deepcopy
  from warnings import warn
  import types
  from scipy.spatial.distance import cdist
  import numpy
  from nibabel.affines import apply_affine
  from nibabel.streamlines import ArraySequence
  from dipy.tracking.streamlinespeed import length, set_number_of_points
  from dipy.tracking.distances import bundles_distances_mdf
  import dipy.tracking.utils
  from dipy.core.geometry import dist_to_corner
  from dipy.core.interpolation import interpolate_vector_3d, interpolate_scalar_3d
label_desc: Use image node_id 10 for calling a global function with example usage: _orient_by_roi_list(out, roi1, roi2) and returns: out