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()]
      )
  
      assert cf.n_train_val_data <= len(
          all_pids_list
      ), "requested {} train val samples, but dataset only has {} train val samples.".format(
          cf.n_train_val_data, len(all_pids_list)
      )
      train_pids = all_pids_list[: int(2 * cf.n_train_val_data // 3)]
      val_pids = all_pids_list[
          int(
              np.ceil(2 * cf.n_train_val_data // 3)
          ) : cf.n_train_val_data
      ]
  
      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 patients".format(
              len(train_pids), len(val_pids)
          )
      )
      batch_gen = {}
      batch_gen["train"] = create_data_gen_pipeline(
          train_data, cf=cf, do_aug=False
      )
      batch_gen["val_sampling"] = create_data_gen_pipeline(
          val_data, cf=cf, do_aug=False
      )
      if cf.val_mode == "val_patient":
          batch_gen["val_patient"] = PatientBatchIterator(
              val_data, cf=cf
          )
          batch_gen["n_val"] = (
              len(val_pids)
              if cf.max_val_patients is None
              else min(len(val_pids), 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