code: def parse_args():
      parser = argparse.ArgumentParser(
          description="Train a model for video action recognition."
      )
      parser.add_argument(
          "--dataset",
          type=str,
          default="ucf101",
          choices=[
              "ucf101",
              "kinetics400",
              "somethingsomethingv2",
              "hmdb51",
              "custom",
          ],
          help="which dataset to use.",
      )
      parser.add_argument(
          "--data-dir",
          type=str,
          default="~/.mxnet/datasets/ucf101/rawframes",
          help="training (and validation) pictures to use.",
      )
      parser.add_argument(
          "--val-data-dir",
          type=str,
          default="~/.mxnet/datasets/ucf101/rawframes",
          help="validation pictures to use.",
      )
      parser.add_argument(
          "--train-list",
          type=str,
          default="~/.mxnet/datasets/ucf101/ucfTrainTestlist/ucf101_train_rgb_split1.txt",
          help="the list of training data",
      )
      parser.add_argument(
          "--val-list",
          type=str,
          default="~/.mxnet/datasets/ucf101/ucfTrainTestlist/ucf101_val_rgb_split1.txt",
          help="the list of validation data",
      )
      parser.add_argument(
          "--batch-size",
          type=int,
          default=25,
          help="training batch size per device (CPU/GPU).",
      )
      parser.add_argument(
          "--dtype",
          type=str,
          default="float32",
          help="data type for training. default is float32",
      )
      parser.add_argument(
          "--num-gpus",
          type=int,
          default=0,
          help="number of gpus to use.",
      )
      parser.add_argument(
          "-j",
          "--num-data-workers",
          dest="num_workers",
          default=4,
          type=int,
          help="number of preprocessing workers",
      )
      parser.add_argument(
          "--num-epochs",
          type=int,
          default=3,
          help="number of training epochs.",
      )
      parser.add_argument(
          "--lr",
          type=float,
          default=0.1,
          help="learning rate. default is 0.1.",
      )
      parser.add_argument(
          "--momentum",
          type=float,
          default=0.9,
          help="momentum value for optimizer, default is 0.9.",
      )
      parser.add_argument(
          "--wd",
          type=float,
          default=0.0001,
          help="weight decay rate. default is 0.0001.",
      )
      parser.add_argument(
          "--lr-mode",
          type=str,
          default="step",
          help="learning rate scheduler mode. options are step, poly and cosine.",
      )
      parser.add_argument(
          "--lr-decay",
          type=float,
          default=0.1,
          help="decay rate of learning rate. default is 0.1.",
      )
      parser.add_argument(
          "--lr-decay-period",
          type=int,
          default=0,
          help="interval for periodic learning rate decays. default is 0 to disable.",
      )
      parser.add_argument(
          "--lr-decay-epoch",
          type=str,
          default="40,60",
          help="epochs at which learning rate decays. default is 40,60.",
      )
      parser.add_argument(
          "--warmup-lr",
          type=float,
          default=0.0,
          help="starting warmup learning rate. default is 0.0.",
      )
      parser.add_argument(
          "--warmup-epochs",
          type=int,
          default=0,
          help="number of warmup epochs.",
      )
      parser.add_argument(
          "--last-gamma",
          action="store_true",
          help="whether to init gamma of the last BN layer in each bottleneck to 0.",
      )
      parser.add_argument(
          "--mode",
          type=str,
          help="mode in which to train the model. options are symbolic, imperative, hybrid",
      )
      parser.add_argument(
          "--model",
          type=str,
          required=True,
          help="type of model to use. see vision_model for options.",
      )
      parser.add_argument(
          "--input-size",
          type=int,
          default=224,
          help="size of the input image size. default is 224",
      )
      parser.add_argument(
          "--crop-ratio",
          type=float,
          default=0.875,
          help="Crop ratio during validation. default is 0.875",
      )
      parser.add_argument(
          "--use-pretrained",
          action="store_true",
          help="enable using pretrained model from gluon.",
      )
      parser.add_argument(
          "--hashtag",
          type=str,
          default="",
          help="hashtag for pretrained models.",
      )
      parser.add_argument(
          "--use_se",
          action="store_true",
          help="use SE layers or not in resnext. default is false.",
      )
      parser.add_argument(
          "--mixup",
          action="store_true",
          help="whether train the model with mix-up. default is false.",
      )
      parser.add_argument(
          "--mixup-alpha",
          type=float,
          default=0.2,
          help="beta distribution parameter for mixup sampling, default is 0.2.",
      )
      parser.add_argument(
          "--mixup-off-epoch",
          type=int,
          default=0,
          help="how many last epochs to train without mixup, default is 0.",
      )
      parser.add_argument(
          "--label-smoothing",
          action="store_true",
          help="use label smoothing or not in training. default is false.",
      )
      parser.add_argument(
          "--no-wd",
          action="store_true",
          help="whether to remove weight decay on bias, and beta/gamma for batchnorm layers.",
      )
      parser.add_argument(
          "--teacher",
          type=str,
          default=None,
          help="teacher model for distillation training",
      )
      parser.add_argument(
          "--temperature",
          type=float,
          default=20,
          help="temperature parameter for distillation teacher model",
      )
      parser.add_argument(
          "--hard-weight",
          type=float,
          default=0.5,
          help="weight for the loss of one-hot label for distillation training",
      )
      parser.add_argument(
          "--batch-norm",
          action="store_true",
          help="enable batch normalization or not in vgg. default is false.",
      )
      parser.add_argument(
          "--save-frequency",
          type=int,
          default=10,
          help="frequency of model saving.",
      )
      parser.add_argument(
          "--save-dir",
          type=str,
          default="params",
          help="directory of saved models",
      )
      parser.add_argument(
          "--resume-epoch",
          type=int,
          default=0,
          help="epoch to resume training from.",
      )
      parser.add_argument(
          "--resume-params",
          type=str,
          default="",
          help="path of parameters to load from.",
      )
      parser.add_argument(
          "--resume-states",
          type=str,
          default="",
          help="path of trainer state to load from.",
      )
      parser.add_argument(
          "--log-interval",
          type=int,
          default=50,
          help="Number of batches to wait before logging.",
      )
      parser.add_argument(
          "--logging-file",
          type=str,
          default="train.log",
          help="name of training log file",
      )
      parser.add_argument(
          "--use-gn",
          action="store_true",
          help="whether to use group norm.",
      )
      parser.add_argument(
          "--eval",
          action="store_true",
          help="directly evaluate the model.",
      )
      parser.add_argument(
          "--num-segments",
          type=int,
          default=1,
          help="number of segments to evenly split the video.",
      )
      parser.add_argument(
          "--use-tsn",
          action="store_true",
          help="whether to use temporal segment networks.",
      )
      parser.add_argument(
          "--new-height",
          type=int,
          default=0,
          help="new height of the resize image. default is 0",
      )
      parser.add_argument(
          "--new-width",
          type=int,
          default=0,
          help="new width of the resize image. default is 0",
      )
      parser.add_argument(
          "--new-length",
          type=int,
          default=1,
          help="new length of video sequence. default is 1",
      )
      parser.add_argument(
          "--new-step",
          type=int,
          default=1,
          help="new step to skip video sequence. default is 1",
      )
      parser.add_argument(
          "--clip-grad",
          type=int,
          default=0,
          help="clip gradient to a certain threshold. Set the value to be larger than zero to enable gradient clipping.",
      )
      parser.add_argument(
          "--partial-bn",
          action="store_true",
          help="whether to freeze bn layers except the first layer.",
      )
      parser.add_argument(
          "--freeze-bn",
          action="store_true",
          help="whether to freeze all the bn layers.",
      )
      parser.add_argument(
          "--num-classes",
          type=int,
          default=101,
          help="number of classes.",
      )
      parser.add_argument(
          "--scale-ratios",
          type=str,
          default="1.0, 0.875, 0.75, 0.66",
          help="Scale ratios used in multi-scale cropping data augmentation technique.",
      )
      parser.add_argument(
          "--use-amp",
          action="store_true",
          help="whether to use automatic mixed precision.",
      )
      parser.add_argument(
          "--prefetch-ratio",
          type=float,
          default=2.0,
          help="set number of workers to prefetch data batch, default is 2 in MXNet.",
      )
      parser.add_argument(
          "--kvstore",
          type=str,
          default=None,
          help="KVStore type. Supports local, device, dist_sync_device, dist_async_device",
      )
      parser.add_argument(
          "--input-5d",
          action="store_true",
          help="the input is 4d or 5d tensor. 5d is for 3D CNN models.",
      )
      parser.add_argument(
          "--video-loader",
          action="store_true",
          help="if set to True, read videos directly instead of reading frames.",
      )
      parser.add_argument(
          "--use-decord",
          action="store_true",
          help="if set to True, use Decord video loader to load data. Otherwise use mmcv video loader.",
      )
      parser.add_argument(
          "--accumulate",
          type=int,
          default=1,
          help="new step to accumulate gradient. If >1, the batch size is enlarged.",
      )
      parser.add_argument(
          "--slowfast",
          action="store_true",
          help="if set to True, use data loader designed for SlowFast network.",
      )
      parser.add_argument(
          "--slow-temporal-stride",
          type=int,
          default=16,
          help="the temporal stride for sparse sampling of video frames for slow branch in SlowFast network.",
      )
      parser.add_argument(
          "--fast-temporal-stride",
          type=int,
          default=2,
          help="the temporal stride for sparse sampling of video frames for fast branch in SlowFast network.",
      )
      parser.add_argument(
          "--num-crop",
          type=int,
          default=1,
          help="number of crops for each image. default is 1",
      )
      parser.add_argument(
          "--data-aug",
          type=str,
          default="v1",
          help="different types of data augmentation pipelines. Supports v1, v2, v3 and v4.",
      )
      parser.add_argument(
          "--train-only",
          action="store_true",
          help="if set to True, no evaluation is performed during training. Only save the last epoch model to speed up training.",
      )
      parser.add_argument(
          "--more-fix-crop",
          action="store_false",
          help="if set to True, enable fixed corner cropping with more corners.",
      )
      parser.add_argument(
          "--max-distort",
          type=int,
          default=1,
          help="maximum image aspect ratio distortion allowed during data augmentation. default is 1",
      )
      opt = parser.parse_args()
      return opt
  
file_path: gluon-cv/scripts/action-recognition/train_recognizer.py
imports: import argparse, time, logging, os, sys, math
  import numpy
  import mxnet
  import gluoncv
  from mxnet import gluon, nd, init, context
  from mxnet import autograd
  from mxnet.gluon import nn
  from mxnet.gluon.data.vision import transforms
  from mxboard import SummaryWriter
  from mxnet.contrib import amp
  from gluoncv.data.transforms import video
  from gluoncv.data import UCF101, Kinetics400, SomethingSomethingV2, HMDB51, VideoClsCustom
  from gluoncv.model_zoo import get_model
  from gluoncv.utils import makedirs, LRSequential, LRScheduler, split_and_load
  from gluoncv.data.sampler import SplitSampler, ShuffleSplitSampler
label_desc: Use image node_id 1 for calling a global function with example usage: parse_args() and returns: opt