code: def get_dataloader(
      net,
      train_dataset,
      val_dataset,
      train_transform,
      val_transform,
      batch_size,
      num_shards,
      args,
  ):
      """Get dataloader."""
      train_bfn = FasterRCNNTrainBatchify(net, num_shards)
      if hasattr(train_dataset, "get_im_aspect_ratio"):
          im_aspect_ratio = train_dataset.get_im_aspect_ratio()
      else:
          im_aspect_ratio = [1.0] * len(train_dataset)
      train_sampler = gcv.data.sampler.SplitSortedBucketSampler(
          im_aspect_ratio,
          batch_size,
          num_parts=hvd.size() if args.horovod else 1,
          part_index=hvd.rank() if args.horovod else 0,
          shuffle=True,
      )
      train_loader = mx.gluon.data.DataLoader(
          train_dataset.transform(
              train_transform(
                  net.short,
                  net.max_size,
                  net,
                  ashape=net.ashape,
                  multi_stage=args.use_fpn,
              )
          ),
          batch_sampler=train_sampler,
          batchify_fn=train_bfn,
          num_workers=args.num_workers,
      )
      val_bfn = Tuple(*[Append() for _ in range(3)])
      short = (
          net.short[-1]
          if isinstance(net.short, (tuple, list))
          else net.short
      )
      # validation use 1 sample per device
      val_loader = mx.gluon.data.DataLoader(
          val_dataset.transform(val_transform(short, net.max_size)),
          num_shards,
          False,
          batchify_fn=val_bfn,
          last_batch="keep",
          num_workers=args.num_workers,
      )
      return train_loader, val_loader
  
imports: import argparse
  import os
  import logging
  import time
  import numpy
  import mxnet
  from mxnet import gluon
  from mxnet.contrib import amp
  import gluoncv
  from gluoncv import data
  from gluoncv import utils
  from gluoncv.model_zoo import get_model
  from gluoncv.data.batchify import FasterRCNNTrainBatchify, Tuple, Append
  from gluoncv.data.transforms.presets.rcnn import FasterRCNNDefaultTrainTransform, FasterRCNNDefaultValTransform
  from gluoncv.utils.metrics.voc_detection import VOC07MApMetric
  from gluoncv.utils.metrics.coco_detection import COCODetectionMetric
  from gluoncv.utils.parallel import Parallel
  from gluoncv.utils.metrics.rcnn import RPNAccMetric, RPNL1LossMetric, RCNNAccMetric, RCNNL1LossMetric
  from gluoncv.model_zoo.rcnn.faster_rcnn.data_parallel import ForwardBackwardTask
label_desc: Use image node_id 3 for calling a global function with example usage: get_dataloader(net, train_dataset, val_dataset, train_transform, val_transform, batch_size, num_shards, args) and returns: train_loader,  val_loader