code: def get_val_data(
      rec_val, batch_size, data_nthreads, input_size, crop_ratio
  ):
      def val_batch_fn(batch, ctx):
          data = batch[0].as_in_context(ctx)
          label = batch[1].as_in_context(ctx)
          return data, label
  
      normalize = transforms.Normalize(
          [0.485, 0.456, 0.406], [0.229, 0.224, 0.225]
      )
      crop_ratio = crop_ratio if crop_ratio > 0 else 0.875
      resize = int(math.ceil(input_size / crop_ratio))
  
      from gluoncv.utils.transforms import EfficientNetCenterCrop
      from autogluon.utils import pil_transforms
  
      if input_size >= 320:
          transform_test = transforms.Compose(
              [
                  pil_transforms.ToPIL(),
                  EfficientNetCenterCrop(input_size),
                  pil_transforms.Resize(
                      (input_size, input_size),
                      interpolation=Image.BICUBIC,
                  ),
                  pil_transforms.ToNDArray(),
                  transforms.ToTensor(),
                  normalize,
              ]
          )
      else:
          transform_test = transforms.Compose(
              [
                  transforms.Resize(resize, keep_ratio=True),
                  transforms.CenterCrop(input_size),
                  transforms.ToTensor(),
                  normalize,
              ]
          )
  
      val_set = mx.gluon.data.vision.ImageRecordDataset(
          rec_val
      ).transform_first(transform_test)
  
      val_sampler = SplitSampler(
          len(val_set), num_parts=num_workers, part_index=rank
      )
      val_data = gluon.data.DataLoader(
          val_set,
          batch_size=batch_size,
          num_workers=data_nthreads,
          sampler=val_sampler,
      )
  
      return val_data, val_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 2 for calling a global function with example usage: get_val_data(rec_val, batch_size, data_nthreads, input_size, crop_ratio) and returns: val_data,  val_batch_fn, data,  label