code: def main(logger, opt):
      """train model"""
      filehandler = logging.FileHandler(
          os.path.join(opt.save_dir, opt.logging_file)
      )
      streamhandler = logging.StreamHandler()
      logger = logging.getLogger("")
      logger.setLevel(logging.INFO)
      logger.addHandler(filehandler)
      logger.addHandler(streamhandler)
      logger.info(opt)
  
      if opt.use_amp:
          amp.init()
  
      num_gpus = opt.ngpus
      batch_size = opt.batch_size * max(1, num_gpus)
      logger.info(
          "Total batch size is set to %d on %d GPUs"
          % (batch_size, num_gpus)
      )
      train_loader = build_data_loader(batch_size)
  
      # create model
      net = get_model(
          opt.model_name,
          bz=opt.batch_size,
          is_train=opt.is_train,
          ctx=opt.ctx,
      )
      net.cast(opt.dtype)
      logger.info(net)
      net.collect_params().reset_ctx(opt.ctx)
      if opt.resume_params is not None:
          if os.path.isfile(opt.resume_params):
              net.load_parameters(opt.resume_params, ctx=opt.ctx)
              print(
                  "Continue training from model %s."
                  % (opt.resume_params)
              )
          else:
              raise RuntimeError(
                  "=> no checkpoint found at '{}'".format(
                      opt.resume_params
                  )
              )
  
      # create criterion
      criterion = SiamRPNLoss(opt.batch_size)
      # optimizer and lr scheduling
      step_epoch = [10, 20, 30, 40, 50]
      num_batches = len(train_loader)
      lr_scheduler = LRSequential(
          [
              LRScheduler(
                  mode="step",
                  base_lr=0.005,
                  target_lr=0.01,
                  nepochs=opt.warmup_epochs,
                  iters_per_epoch=num_batches,
                  step_epoch=step_epoch,
              ),
              LRScheduler(
                  mode="poly",
                  base_lr=0.01,
                  target_lr=0.005,
                  nepochs=opt.epochs - opt.warmup_epochs,
                  iters_per_epoch=num_batches,
                  step_epoch=[
                      e - opt.warmup_epochs for e in step_epoch
                  ],
                  power=0.02,
              ),
          ]
      )
  
      optimizer_params = {
          "lr_scheduler": lr_scheduler,
          "wd": opt.weight_decay,
          "momentum": opt.momentum,
          "learning_rate": opt.lr,
      }
  
      if opt.dtype == "float32":
          optimizer_params["multi_precision"] = True
  
      if opt.use_amp:
          amp.init_trainer(optimizer_params)
  
      if opt.no_wd:
          for k, v in net.module.collect_params(
              ".*beta|.*gamma|.*bias"
          ).items():
              v.wd_mult = 0.0
  
      if opt.mode == "hybrid":
          net.hybridize(static_alloc=True, static_shape=True)
  
      optimizer = gluon.Trainer(
          net.collect_params(), "sgd", optimizer_params
      )
  
      if opt.accumulate > 1:
          params = [
              p
              for p in net.collect_params().values()
              if p.grad_req != "null"
          ]
          for p in params:
              p.grad_req = "add"
  
      train(
          opt,
          net,
          train_loader,
          criterion,
          optimizer,
          batch_size,
          logger,
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import argparse
  import logging
  import os
  import time
  import numpy
  import mxnet
  from mxnet import gluon, nd, autograd
  from mxnet.contrib import amp
  from gluoncv.utils import LRScheduler, LRSequential, split_and_load
  from gluoncv.data.tracking_data.track import TrkDataset
  from gluoncv.model_zoo import get_model
  from gluoncv.loss import SiamRPNLoss
label_desc: Use image node_id 4 for calling a global function with example usage: main(logger, opt) without return types