code: def get_data(train_or_test, isMixup, alpha):
      isTrain = train_or_test == "train"
      ds = dataset.Cifar10(train_or_test)
      if isTrain:
          augmentors = [
              imgaug.CenterPaste((40, 40)),
              imgaug.RandomCrop((32, 32)),
              imgaug.Flip(horiz=True),
          ]
          ds = AugmentImageComponent(ds, augmentors)
  
      batch = BATCH_SIZE
      ds = BatchData(ds, batch, remainder=not isTrain)
  
      def f(dp):
          images, labels = dp
          one_hot_labels = np.eye(CLASS_NUM)[labels]  # one hot coding
          if not isTrain or not isMixup:
              return [images, one_hot_labels]
  
          # mixup implementation:
          # Note that for larger images, it's more efficient to do mixup on GPUs (i.e. in the graph)
          weight = np.random.beta(alpha, alpha, BATCH_SIZE)
          x_weight = weight.reshape(BATCH_SIZE, 1, 1, 1)
          y_weight = weight.reshape(BATCH_SIZE, 1)
          index = np.random.permutation(BATCH_SIZE)
  
          x1, x2 = images, images[index]
          x = x1 * x_weight + x2 * (1 - x_weight)
          y1, y2 = one_hot_labels, one_hot_labels[index]
          y = y1 * y_weight + y2 * (1 - y_weight)
          return [x, y]
  
      ds = MapData(ds, f)
      return ds
  
file_path: tensorpack/examples/ResNet/cifar10-preact18-mixup.py
imports: import argparse
  import numpy
  import os
  from tensorpack import *
  from tensorpack.compat import tfv1
  from tensorpack.dataflow import dataset
  from tensorpack.tfutils.summary import *
label_desc: Use image node_id 2 for calling a global function with example usage: get_data(train_or_test, isMixup, alpha) and returns: ds, list, list