code: def get_imagenet_dataflow(
      datadir, name, batch_size, augmentors=None, parallel=None
  ):
      """
      Args:
          augmentors (list[imgaug.Augmentor]): Defaults to `fbresnet_augmentor(isTrain)`
  
      Returns: A DataFlow which produces BGR images and labels.
  
      See explanations in the tutorial:
      http://tensorpack.readthedocs.io/tutorial/efficient-dataflow.html
      """
      assert name in ["train", "val", "test"]
      isTrain = name == "train"
      assert datadir is not None
      if augmentors is None:
          augmentors = fbresnet_augmentor(isTrain)
      assert isinstance(augmentors, list)
      if parallel is None:
          parallel = min(
              40, multiprocessing.cpu_count() // 2
          )  # assuming hyperthreading
  
      if isTrain:
          ds = dataset.ILSVRC12(datadir, name, shuffle=True)
          ds = AugmentImageComponent(ds, augmentors, copy=False)
          if parallel < 16:
              logger.warn(
                  "DataFlow may become the bottleneck when too few processes are used."
              )
          ds = MultiProcessRunnerZMQ(ds, parallel)
          ds = BatchData(ds, batch_size, remainder=False)
      else:
          ds = dataset.ILSVRC12Files(datadir, name, shuffle=False)
          aug = imgaug.AugmentorList(augmentors)
  
          def mapf(dp):
              fname, cls = dp
              im = cv2.imread(fname, cv2.IMREAD_COLOR)
              im = aug.augment(im)
              return im, cls
  
          ds = MultiThreadMapData(
              ds, parallel, mapf, buffer_size=2000, strict=True
          )
          ds = BatchData(ds, batch_size, remainder=True)
          ds = MultiProcessRunnerZMQ(ds, 1)
      return ds
  
imports: import multiprocessing
  import numpy
  import os
  from abc import abstractmethod
  import cv2
  import tqdm
  from tensorpack import tfv1
  from tensorpack import ModelDesc
  from tensorpack.dataflow import AugmentImageComponent, BatchData, MultiThreadMapData, MultiProcessRunnerZMQ, dataset, imgaug
  from tensorpack.input_source import QueueInput, StagingInput
  from tensorpack.models import regularize_cost, l2_regularizer
  from tensorpack.predict import FeedfreePredictor, PredictConfig
  from tensorpack.tfutils.summary import add_moving_summary
  from tensorpack.tfutils.optimizer import AccumGradOptimizer
  from tensorpack.utils import logger
  from tensorpack.utils.stats import RatioCounter
label_desc: Use image node_id 2 for calling a global function with example usage: get_imagenet_dataflow(datadir, name, batch_size, augmentors, parallel) and returns: ds, im,  cls