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.nn.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,
      )
      if val_dataset is None:
          val_loader = None
      else:
          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 gluoncv
  import mxnet
  import numpy
  from data import *
  from gluoncv import data, utils
  from gluoncv.data.batchify import Append, FasterRCNNTrainBatchify, Tuple
  from gluoncv.data.transforms.presets.rcnn import FasterRCNNDefaultTrainTransform, FasterRCNNDefaultValTransform
  from gluoncv.model_zoo import get_model
  from gluoncv.utils.metrics.coco_detection import COCODetectionMetric
  from gluoncv.utils.metrics.rcnn import RCNNAccMetric, RCNNL1LossMetric, RPNAccMetric, RPNL1LossMetric
  from gluoncv.utils.metrics.voc_detection import VOC07MApMetric
  from gluoncv.utils.parallel import Parallel, Parallelizable
  from model import faster_rcnn_resnet101_v1d_custom, faster_rcnn_resnet50_v1b_custom
  from mxnet import autograd, gluon
  from mxnet.contrib import amp
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