code: def get_train_data(
      rec_train, batch_size, data_nthreads, input_size, crop_ratio, args
  ):
      def train_batch_fn(batch, ctx):
          data = batch[0].as_in_context(ctx)
          label = batch[1].as_in_context(ctx)
          return data, label
  
      jitter_param = 0.4
      lighting_param = 0.1
      resize = int(math.ceil(input_size / crop_ratio))
  
      train_transforms = []
      if args.auto_aug:
          print("Using AutoAugment")
          from autogluon.utils.augment import (
              AugmentationBlock,
              autoaug_imagenet_policies,
          )
  
          train_transforms.append(
              AugmentationBlock(autoaug_imagenet_policies())
          )
  
      from gluoncv.utils.transforms import EfficientNetRandomCrop
      from autogluon.utils import pil_transforms
  
      if input_size >= 320:
          train_transforms.extend(
              [
                  EfficientNetRandomCrop(input_size),
                  pil_transforms.Resize(
                      (input_size, input_size),
                      interpolation=Image.BICUBIC,
                  ),
                  pil_transforms.RandomHorizontalFlip(),
                  pil_transforms.ColorJitter(
                      brightness=0.4, contrast=0.4, saturation=0.4
                  ),
                  transforms.RandomLighting(lighting_param),
                  transforms.ToTensor(),
                  transforms.Normalize(
                      [0.485, 0.456, 0.406], [0.229, 0.224, 0.225]
                  ),
              ]
          )
      else:
          train_transforms.extend(
              [
                  transforms.RandomResizedCrop(input_size),
                  transforms.RandomFlipLeftRight(),
                  transforms.RandomColorJitter(
                      brightness=jitter_param,
                      contrast=jitter_param,
                      saturation=jitter_param,
                  ),
                  transforms.RandomLighting(lighting_param),
                  transforms.ToTensor(),
                  transforms.Normalize(
                      [0.485, 0.456, 0.406], [0.229, 0.224, 0.225]
                  ),
              ]
          )
  
      transform_train = transforms.Compose(train_transforms)
  
      train_set = mx.gluon.data.vision.ImageRecordDataset(
          rec_train
      ).transform_first(transform_train)
      train_sampler = SplitSampler(
          len(train_set), num_parts=num_workers, part_index=rank
      )
  
      train_data = gluon.data.DataLoader(
          train_set,
          batch_size=batch_size,  # shuffle=True,
          last_batch="discard",
          num_workers=data_nthreads,
          sampler=train_sampler,
      )
      return train_data, train_batch_fn
  
imports: import os
  import argparse
  import logging
  import math
  import time
  import random
  import gluoncv
  from gluoncv.model_zoo import get_model
  from gluoncv.utils import makedirs
  import horovod.mxnet
  import mxnet
  import numpy
  from mxnet import autograd, gluon, lr_scheduler
  from mxnet.io import DataBatch, DataIter
  from mxnet.gluon.data.vision import transforms
  from PIL import Image
  from gluoncv.nn.dropblock import DropBlockScheduler
label_desc: Use image node_id 1 for calling a global function with example usage: get_train_data(rec_train, batch_size, data_nthreads, input_size, crop_ratio, args) and returns: train_data,  train_batch_fn, data,  label