code: def get_train_generators(cf, logger):
      """
      wrapper function for creating the training batch generator pipeline. returns the train/val generators.
      selects patients according to cv folds (generated by first run/fold of experiment):
      splits the data into n-folds, where 1 split is used for val, 1 split for testing and the rest for training. (inner loop test set)
      If cf.hold_out_test_set is True, adds the test split to the training data.
      """
      all_data = load_dataset(cf, logger)
      all_pids_list = np.unique(
          [v["pid"] for (k, v) in all_data.items()]
      )
  
      if not cf.created_fold_id_pickle:
          fg = dutils.fold_generator(
              seed=cf.seed,
              n_splits=cf.n_cv_splits,
              len_data=len(all_pids_list),
          ).get_fold_names()
          with open(
              os.path.join(cf.exp_dir, "fold_ids.pickle"), "wb"
          ) as handle:
              pickle.dump(fg, handle)
          cf.created_fold_id_pickle = True
      else:
          with open(
              os.path.join(cf.exp_dir, "fold_ids.pickle"), "rb"
          ) as handle:
              fg = pickle.load(handle)
  
      train_ix, val_ix, test_ix, _ = fg[cf.fold]
  
      train_pids = [all_pids_list[ix] for ix in train_ix]
      val_pids = [all_pids_list[ix] for ix in val_ix]
  
      if cf.hold_out_test_set:
          train_pids += [all_pids_list[ix] for ix in test_ix]
  
      train_data = {
          k: v
          for (k, v) in all_data.items()
          if any(p == v["pid"] for p in train_pids)
      }
      val_data = {
          k: v
          for (k, v) in all_data.items()
          if any(p == v["pid"] for p in val_pids)
      }
  
      logger.info(
          "data set loaded with: {} train / {} val / {} test patients".format(
              len(train_ix), len(val_ix), len(test_ix)
          )
      )
      batch_gen = {}
      batch_gen["train"] = create_data_gen_pipeline(
          train_data, cf=cf, is_training=True
      )
      batch_gen["val_sampling"] = create_data_gen_pipeline(
          val_data, cf=cf, is_training=False
      )
      if cf.val_mode == "val_patient":
          batch_gen["val_patient"] = PatientBatchIterator(
              val_data, cf=cf
          )
          batch_gen["n_val"] = (
              len(val_ix)
              if cf.max_val_patients is None
              else min(len(val_ix), cf.max_val_patients)
          )
      else:
          batch_gen["n_val"] = cf.num_val_batches
  
      return batch_gen
  
imports: import numpy
  import os
  from collections import OrderedDict
  import pandas
  import pickle
  import time
  import subprocess
  import utils.dataloader_utils
  from batchgenerators.dataloading.data_loader import SlimDataLoaderBase
  from batchgenerators.transforms.spatial_transforms import MirrorTransform
  from batchgenerators.transforms.abstract_transforms import Compose
  from batchgenerators.dataloading.multi_threaded_augmenter import MultiThreadedAugmenter
  from batchgenerators.dataloading import SingleThreadedAugmenter
  from batchgenerators.transforms.spatial_transforms import SpatialTransform
  from batchgenerators.transforms.crop_and_pad_transforms import CenterCropTransform
  from batchgenerators.transforms.utility_transforms import ConvertSegToBoundingBoxCoordinates
label_desc: Use image node_id 1 for calling a global function with example usage: get_train_generators(cf, logger) and returns: batch_gen