code: def test_apply_affine_transform():
      with TemporaryDirectory() as temp_out_dir:
          factors = {
              ("TRANSLATION", 3): (
                  2.0,
                  None,
                  np.array([2.3, 4.5, 1.7]),
              ),
              ("RIGID", 3): (
                  0.1,
                  None,
                  np.array([0.1, 0.15, -0.11, 2.3, 4.5, 1.7]),
              ),
              ("RIGIDISOSCALING", 3): (
                  0.1,
                  None,
                  np.array([0.1, 0.15, -0.11, 2.3, 4.5, 1.7, 0.8]),
              ),
              ("RIGIDSCALING", 3): (
                  0.1,
                  None,
                  np.array(
                      [0.1, 0.15, -0.11, 2.3, 4.5, 1.7, 0.8, 0.9, 1.1]
                  ),
              ),
              ("AFFINE", 3): (
                  0.1,
                  None,
                  np.array(
                      [
                          0.99,
                          -0.05,
                          0.03,
                          1.3,
                          0.05,
                          0.99,
                          -0.10,
                          2.5,
                          -0.07,
                          0.10,
                          0.99,
                          -1.4,
                      ]
                  ),
              ),
          }
  
          image_registration_flow = ImageRegistrationFlow()
          apply_trans = ApplyTransformFlow()
  
          for i in factors.keys():
              (
                  static,
                  moving,
                  static_g2w,
                  moving_g2w,
                  smask,
                  mmask,
                  M,
              ) = setup_random_transform(
                  transform=regtransforms[i], rfactor=factors[i][0]
              )
  
              stat_file = str(i[0]) + "_static.nii.gz"
              mov_file = str(i[0]) + "_moving.nii.gz"
  
              save_nifti(
                  pjoin(temp_out_dir, stat_file),
                  data=static,
                  affine=static_g2w,
              )
  
              save_nifti(
                  pjoin(temp_out_dir, mov_file),
                  data=moving,
                  affine=moving_g2w,
              )
  
              static_image_file = pjoin(
                  temp_out_dir, str(i[0]) + "_static.nii.gz"
              )
              moving_image_file = pjoin(
                  temp_out_dir, str(i[0]) + "_moving.nii.gz"
              )
  
              out_moved = pjoin(
                  temp_out_dir, str(i[0]) + "_moved.nii.gz"
              )
              out_affine = pjoin(
                  temp_out_dir, str(i[0]) + "_affine.txt"
              )
  
              if str(i[0]) == "TRANSLATION":
                  transform_type = "trans"
              elif str(i[0]) == "RIGIDISOSCALING":
                  transform_type = "rigid_isoscaling"
              elif str(i[0]) == "RIGIDSCALING":
                  transform_type = "rigid_scaling"
              else:
                  transform_type = str(i[0]).lower()
  
              image_registration_flow.run(
                  static_image_file,
                  moving_image_file,
                  transform=transform_type,
                  out_dir=temp_out_dir,
                  out_moved=out_moved,
                  out_affine=out_affine,
                  level_iters=[1, 1, 1],
                  save_metric=False,
              )
  
              # Checking for the created moved file.
              assert os.path.exists(out_moved)
              assert os.path.exists(out_affine)
  
          images = pjoin(temp_out_dir, "*moving*")
          apply_trans.run(
              static_image_file,
              images,
              out_dir=temp_out_dir,
              transform_map_file=out_affine,
          )
  
          # Checking for the transformed file.
          assert os.path.exists(
              pjoin(temp_out_dir, "transformed.nii.gz")
          )
  
imports: from os.path import join
  import os.path
  from tempfile import TemporaryDirectory
  import numpy.testing
  import numpy
  import nibabel
  import pytest
  from dipy.utils.optpkg import optional_package
  from dipy.align.tests.test_imwarp import get_synthetic_warped_circle
  from dipy.align.tests.test_parzenhist import setup_random_transform
  from dipy.align.transforms import regtransforms
  from dipy.data import get_fnames
  from dipy.io.image import save_nifti, load_nifti_data
  from dipy.io.stateful_tractogram import Space, StatefulTractogram
  from dipy.io.streamline import load_tractogram, save_tractogram
  from dipy.tracking.streamline import Streamlines
  from dipy.workflows.align import ImageRegistrationFlow, SynRegistrationFlow, ApplyTransformFlow, ResliceFlow, SlrWithQbxFlow, MotionCorrectionFlow, BundleWarpFlow
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 5 for calling a global function with example usage: test_apply_affine_transform() without return types