code: def main(args):
      if not args.cfg:
          raise RuntimeError("No configuration file specified.")
      cfg = Config(
          args.cfg,
          learning_rate=args.learning_rate,
          iters=args.iters,
          batch_size=args.batch_size,
          opts=args.opts,
      )
      builder = SegBuilder(cfg)
  
      utils.show_env_info()
      utils.show_cfg_info(cfg)
      utils.set_seed(args.seed)
      utils.set_device(args.device)
  
      model = builder.model
      train_dataset = builder.train_dataset
      val_dataset = builder.val_dataset if args.do_eval else None
      losses = builder.loss
      optimizer = builder.optimizer
  
      if args.model_path:
          utils.load_entire_model(model, args.model_path)
          logger.info("Loaded trained params of model successfully")
  
      skip_quant(model)
      quantizer = QAT(config=quant_config)
      quantizer.quantize(model)
      logger.info("Quantize the model successfully")
  
      train(
          model,
          train_dataset,
          val_dataset=val_dataset,
          optimizer=optimizer,
          save_dir=args.save_dir,
          iters=cfg.iters,
          batch_size=cfg.batch_size,
          resume_model=None,
          save_interval=args.save_interval,
          log_iters=args.log_iters,
          num_workers=args.num_workers,
          use_vdl=args.use_vdl,
          losses=losses,
          keep_checkpoint_max=args.keep_checkpoint_max,
      )
  
file_path: PaddleSeg/deploy/slim/quant/qat_train.py
imports: import argparse
  import random
  import paddle
  import numpy
  from paddleslim import QAT
  from paddleseg.cvlibs import Config, SegBuilder
  from paddleseg.core import train
  from paddleseg.utils import get_sys_env, logger, utils
  from qat_config import quant_config
label_desc: Use image node_id 3 for calling a global function with example usage: main(args) without return types