class_docstr: creates the training/validation batch generator. Samples n_batch_size patients (draws a slice from each patient if 2D)
  from the data set while maintaining foreground-class balance. Returned patches are cropped/padded to pre_crop_size.
  Actual patch_size is obtained after data augmentation.
  :param data: data dictionary as provided by 'load_dataset'.
  :param batch_size: number of patients to sample for the batch
  :return dictionary containing the batch data (b, c, x, y, (z)) / seg (b, 1, x, y, (z)) / pids / class_target
class_docstr_tok: ["creates","the","training\/validation","batch","generator",".","Samples","n_batch_size","patients","(","draws","a","slice","from","each","patient","if","2D",")","from","the","data","set","while","maintaining","foreground-class","balance",".","Returned","patches","are","cropped\/padded","to","pre_crop_size",".","Actual","patch_size","is","obtained","after","data","augmentation",".",":","param","data",":","data","dictionary","as","provided","by","'load_dataset","'",".",":","param","batch_size",":","number","of","patients","to","sample","for","the","batch",":","return","dictionary","containing","the","batch","data","(","b",",","c",",","x",",","y",",","(","z",")",")","\/","seg","(","b",",","1",",","x",",","y",",","(","z",")",")","\/","pids","\/","class_target"]
code: def __init__(self, data, batch_size, cf):
      super(BatchGenerator, self).__init__(data, batch_size)
  
      self.cf = cf
      self.crop_margin = (
          np.array(self.cf.patch_size) / 8.0
      )  # min distance of ROI center to edge of cropped_patch.
      self.p_fg = 0.5
  
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 to create a new BatchGenerator object from inherited base classes: SlimDataLoaderBase with example: obj = BatchGenerator(data, batch_size, cf)