code: def transform_streamlines(streamlines, mat, in_place=False):
      """Apply affine transformation to streamlines
  
      Parameters
      ----------
      streamlines : Streamlines
          Streamlines object
      mat : array, (4, 4)
          transformation matrix
      in_place : bool
          If True then change data in place.
          Be careful changes input streamlines.
  
      Returns
      -------
      new_streamlines : Streamlines
          Sequence transformed 2D ndarrays of shape[-1]==3
      """
      # using new Streamlines API
      if isinstance(streamlines, Streamlines):
          old_data_dtype = streamlines._data.dtype
          old_offsets_dtype = streamlines._offsets.dtype
          if in_place:
              streamlines._data = apply_affine(
                  mat, streamlines._data
              ).astype(old_data_dtype)
              return streamlines
          new_streamlines = streamlines.copy()
          new_streamlines._offsets = new_streamlines._offsets.astype(
              old_offsets_dtype
          )
          if new_streamlines._data.size:
              new_streamlines._data = apply_affine(
                  mat, new_streamlines._data
              ).astype(old_data_dtype)
          return new_streamlines
      # supporting old data structure of streamlines
      return [apply_affine(mat, s) for s in streamlines]
  
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 5 for calling a global function with example usage: transform_streamlines(streamlines, mat, in_place) and returns: unknown, new_streamlines, streamlines