code: def main():
      args = parse_args()
  
      # load config
      cfg = Config.fromfile(args.config)
      cfg.launcher = args.launcher
      if args.cfg_options is not None:
          cfg.merge_from_dict(args.cfg_options)
  
      # work_dir is determined in this priority: CLI > segment in file > filename
      if args.work_dir is not None:
          # update configs according to CLI args if args.work_dir is not None
          cfg.work_dir = args.work_dir
      elif cfg.get("work_dir", None) is None:
          # use config filename as default work_dir if cfg.work_dir is None
          cfg.work_dir = osp.join(
              "./work_dirs", osp.splitext(osp.basename(args.config))[0]
          )
      # enable automatic-mixed-precision training
      if args.amp:
          optim_wrapper = cfg.optim_wrapper.type
          if optim_wrapper == "AmpOptimWrapper":
              print_log(
                  "AMP training is already enabled in your config.",
                  logger="current",
                  level=logging.WARNING,
              )
          else:
              assert optim_wrapper == "OptimWrapper", (
                  "`--amp` is only supported when the optimizer wrapper type is "
                  f"`OptimWrapper` but got {optim_wrapper}."
              )
              cfg.optim_wrapper.type = "AmpOptimWrapper"
              cfg.optim_wrapper.loss_scale = "dynamic"
  
      if args.resume:
          cfg.resume = True
  
      # enable automatically scaling LR
      if args.auto_scale_lr:
          if (
              "auto_scale_lr" in cfg
              and "base_batch_size" in cfg.auto_scale_lr
          ):
              cfg.auto_scale_lr.enable = True
          else:
              raise RuntimeError(
                  'Can not find "auto_scale_lr" or '
                  '"auto_scale_lr.base_batch_size" in your'
                  " configuration file."
              )
  
      # build the runner from config
      if "runner_type" not in cfg:
          # build the default runner
          runner = Runner.from_cfg(cfg)
      else:
          # build customized runner from the registry
          # if 'runner_type' is set in the cfg
          runner = RUNNERS.build(cfg)
  
      # start training
      runner.train()
  
file_path: mmocr/tools/train.py
imports: import argparse
  import logging
  import os
  import os.path
  from mmengine.config import Config, DictAction
  from mmengine.logging import print_log
  from mmengine.registry import RUNNERS
  from mmengine.runner import Runner
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types