code: def get_data(name):
      isTrain = name == "train"
      ds = dataset.BSDS500(name, shuffle=True)
  
      class CropMultiple16(imgaug.ImageAugmentor):
          def get_transform(self, img):
              newh = img.shape[0] // 16 * 16
              neww = img.shape[1] // 16 * 16
              assert newh > 0 and neww > 0
              diffh = img.shape[0] - newh
              h0 = 0 if diffh == 0 else self.rng.randint(diffh)
              diffw = img.shape[1] - neww
              w0 = 0 if diffw == 0 else self.rng.randint(diffw)
              return imgaug.CropTransform(h0, w0, newh, neww)
  
      if isTrain:
          shape_aug = [
              imgaug.RandomResize(
                  xrange=(0.7, 1.5),
                  yrange=(0.7, 1.5),
                  aspect_ratio_thres=0.15,
              ),
              imgaug.RotationAndCropValid(90),
              CropMultiple16(),
              imgaug.Flip(horiz=True),
              imgaug.Flip(vert=True),
          ]
      else:
          # the original image shape (321x481) in BSDS is not a multiple of 16
          IMAGE_SHAPE = (320, 480)
          shape_aug = [imgaug.CenterCrop(IMAGE_SHAPE)]
      ds = AugmentImageComponents(ds, shape_aug, (0, 1), copy=False)
  
      def f(m):  # thresholding
          m[m >= 0.50] = 1
          m[m < 0.50] = 0
          return m
  
      ds = MapDataComponent(ds, f, 1)
  
      if isTrain:
          augmentors = [
              imgaug.Brightness(63, clip=False),
              imgaug.Contrast((0.4, 1.5)),
          ]
          ds = AugmentImageComponent(ds, augmentors, copy=False)
          ds = BatchDataByShape(ds, 8, idx=0)
          ds = MultiProcessRunnerZMQ(ds, 1)
      else:
          ds = BatchData(ds, 1)
      return ds
  
imports: import argparse
  import numpy
  import os
  import cv2
  import tensorflow
  from tensorpack import *
  from tensorpack.dataflow import dataset
  from tensorpack.tfutils import gradproc, optimizer
  from tensorpack.tfutils.summary import add_moving_summary, add_param_summary
  from tensorpack.utils.gpu import get_num_gpu
  from tensorpack.utils import logger
label_desc: Use image node_id 3 for calling a global function with example usage: get_data(name) and returns: ds, m, imgaug