code: def get_rec_iter(args, kv=None):
      image_shape = tuple([int(l) for l in args.image_shape.split(",")])
      if "benchmark" in args and args.benchmark:
          data_shape = (args.batch_size,) + image_shape
          train = SyntheticDataIter(
              args.num_classes, data_shape, 1000, np.float32
          )
          return (train, None)
      if kv:
          (rank, nworker) = (kv.rank, kv.num_workers)
      else:
          (rank, nworker) = (0, 1)
      rgb_mean = [float(i) for i in args.rgb_mean.split(",")]
      train = mx.io.ImageRecordIter(
          path_imgrec=args.data_train,
          path_imgidx=args.data_train_idx,
          label_width=1,
          mean_r=rgb_mean[0],
          mean_g=rgb_mean[1],
          mean_b=rgb_mean[2],
          data_name="data",
          label_name="softmax_label",
          data_shape=image_shape,
          batch_size=args.batch_size,
          rand_crop=args.random_crop,
          max_random_scale=args.max_random_scale,
          pad=args.pad_size,
          fill_value=127,
          min_random_scale=args.min_random_scale,
          max_aspect_ratio=args.max_random_aspect_ratio,
          random_h=args.max_random_h,
          random_s=args.max_random_s,
          random_l=args.max_random_l,
          max_rotate_angle=args.max_random_rotate_angle,
          max_shear_ratio=args.max_random_shear_ratio,
          rand_mirror=args.random_mirror,
          preprocess_threads=args.data_nthreads,
          shuffle=True,
          num_parts=nworker,
          part_index=rank,
      )
      if args.data_val is None:
          return (train, None)
      val = mx.io.ImageRecordIter(
          path_imgrec=args.data_val,
          path_imgidx=args.data_val_idx,
          label_width=1,
          mean_r=rgb_mean[0],
          mean_g=rgb_mean[1],
          mean_b=rgb_mean[2],
          data_name="data",
          label_name="softmax_label",
          batch_size=args.batch_size,
          data_shape=image_shape,
          preprocess_threads=args.data_nthreads,
          rand_crop=False,
          rand_mirror=False,
          num_parts=nworker,
          part_index=rank,
      )
      return (train, val)
  
file_path: DALI/docs/examples/use_cases/mxnet/resnetn/common/data.py
imports: import mxnet
  import random
  from mxnet.io import DataBatch, DataIter
  import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: get_rec_iter(args, kv) and returns: train,  val, train,  None, train,  None