code: def get_initialised_driver(
      starting_iter=0,
      model_dir_rand=True,
      vars_to_restore="",
      application="tests.toy_application.ToyApplication",
  ):
      if model_dir_rand:
          model_dir = os.path.join(
              ".", "testing_data", "tmp", str(uuid.uuid4())
          )
          os.makedirs(model_dir)
      else:
          model_dir = os.path.join(".", "testing_data")
      system_param = {
          "SYSTEM": ParserNamespace(
              action="train",
              num_threads=2,
              num_gpus=4,
              cuda_devices="6",
              model_dir=model_dir,
              dataset_split_file=os.path.join(
                  ".", "testing_data", "testtoyapp.csv"
              ),
              event_handler=[
                  "niftynet.engine.handler_model.ModelRestorer",
                  "niftynet.engine.handler_sampler.SamplerThreading",
                  "niftynet.engine.handler_gradient.ApplyGradients",
              ],
              iteration_generator=None,
          ),
          "NETWORK": ParserNamespace(
              batch_size=20, name="tests.toy_application.TinyNet"
          ),
          "TRAINING": ParserNamespace(
              starting_iter=starting_iter,
              max_iter=500,
              save_every_n=20,
              tensorboard_every_n=1,
              max_checkpoints=20,
              optimiser="niftynet.engine.application_optimiser.Adagrad",
              validation_every_n=-1,
              exclude_fraction_for_validation=0.1,
              exclude_fraction_for_inference=0.1,
              vars_to_restore=vars_to_restore,
              patience=100,
              lr=0.01,
          ),
          "CUSTOM": ParserNamespace(
              vector_size=100, mean=10.0, stddev=2.0, name=application
          ),
      }
      app_driver = ApplicationDriver()
      app_driver.initialise_application(system_param, {})
      # set parameters without __init__
      app_driver.app.action_param = system_param["TRAINING"]
      app_driver.app.net_param = system_param["NETWORK"]
      app_driver.app.action = "train"
      return app_driver
  
imports: from __future__ import absolute_import, print_function
  import os
  import uuid
  import numpy
  import tensorflow
  from niftynet.engine.application_driver import ApplicationDriver
  from niftynet.engine.application_variables import global_vars_init_or_restore
  from niftynet.engine.handler_model import ModelRestorer
  from niftynet.io.misc_io import set_logger
  from niftynet.utilities.util_common import ParserNamespace
  from niftynet.engine.signal import SESS_FINISHED, SESS_STARTED
  from tests.niftynet_testcase import NiftyNetTestCase
label_desc: Use image node_id 1 for calling a global function with example usage: get_initialised_driver(starting_iter, model_dir_rand, vars_to_restore, application) and returns: app_driver