code: def _orient_by_sl_list(out, std_array, fgarray):
      """Helper function that implements the sequence version of this"""
      for idx, sl in enumerate(fgarray):
          dist_direct = np.sum(
              np.sqrt(np.sum((sl - std_array) ** 2, -1))
          )
          dist_flipped = np.sum(
              np.sqrt(np.sum((sl[::-1] - std_array) ** 2, -1))
          )
          if dist_direct > dist_flipped:
              out[idx][:, 0] = out[idx][::-1][:, 0]
              out[idx][:, 1] = out[idx][::-1][:, 1]
              out[idx][:, 2] = out[idx][::-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 13 for calling a global function with example usage: _orient_by_sl_list(out, std_array, fgarray) and returns: out