code: def get_test_generator(cf, logger):
      """
      wrapper function for creating the test batch generator pipeline.
      selects patients according to cv folds (generated by first run/fold of experiment)
      If cf.hold_out_test_set is True, gets the data from an external folder instead.
      """
      if cf.hold_out_test_set:
          pp_name = cf.pp_test_name
          test_ix = None
      else:
          pp_name = None
          with open(
              os.path.join(cf.exp_dir, "fold_ids.pickle"), "rb"
          ) as handle:
              fold_list = pickle.load(handle)
          _, _, test_ix, _ = fold_list[cf.fold]
          # warnings.warn('WARNING: using validation set for testing!!!')
  
      test_data = load_dataset(
          cf,
          logger,
          test_ix,
          pp_data_path=cf.pp_test_data_path,
          pp_name=pp_name,
      )
      logger.info(
          "data set loaded with: {} test patients from {}".format(
              len(test_data.keys()), cf.pp_test_data_path
          )
      )
      batch_gen = {}
      batch_gen["test"] = PatientBatchIterator(test_data, cf=cf)
      batch_gen["n_test"] = (
          len(test_data.keys())
          if cf.max_test_patients == "all"
          else min(cf.max_test_patients, len(test_data.keys()))
      )
  
      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 2 for calling a global function with example usage: get_test_generator(cf, logger) and returns: batch_gen