code: def run(FLAGS, cfg):
      # init fleet environment
      if cfg.fleet:
          init_fleet_env(cfg.get("find_unused_parameters", False))
      else:
          # init parallel environment if nranks > 1
          init_parallel_env()
  
      if FLAGS.enable_ce:
          set_random_seed(0)
  
      # build trainer
      ssod_method = cfg.get("ssod_method", None)
      if ssod_method is not None:
          if ssod_method == "DenseTeacher":
              trainer = Trainer_DenseTeacher(cfg, mode="train")
          elif ssod_method == "ARSL":
              trainer = Trainer_ARSL(cfg, mode="train")
          elif ssod_method == "Semi_RTDETR":
              trainer = Trainer_Semi_RTDETR(cfg, mode="train")
          else:
              raise ValueError(
                  "Semi-Supervised Object Detection only no support this method."
              )
      elif cfg.get("use_cot", False):
          trainer = TrainerCot(cfg, mode="train")
      else:
          trainer = Trainer(cfg, mode="train")
  
      # load weights
      if FLAGS.resume is not None:
          trainer.resume_weights(FLAGS.resume)
      elif (
          "pretrain_student_weights" in cfg
          and "pretrain_teacher_weights" in cfg
          and cfg.pretrain_teacher_weights
          and cfg.pretrain_student_weights
      ):
          trainer.load_semi_weights(
              cfg.pretrain_teacher_weights, cfg.pretrain_student_weights
          )
      elif "pretrain_weights" in cfg and cfg.pretrain_weights:
          trainer.load_weights(cfg.pretrain_weights)
  
      # training
      trainer.train(FLAGS.eval)
  
file_path: PaddleDetection/tools/train.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import sys
  import warnings
  import paddle
  from ppdet.core.workspace import load_config, merge_config
  from ppdet.engine import Trainer, TrainerCot, init_parallel_env, set_random_seed, init_fleet_env
  from ppdet.engine.trainer_ssod import Trainer_DenseTeacher, Trainer_ARSL, Trainer_Semi_RTDETR
  from ppdet.slim import build_slim_model
  from ppdet.utils.cli import ArgsParser, merge_args
  import ppdet.utils.check
  from ppdet.utils.logger import setup_logger
label_desc: Use image node_id 2 for calling a global function with example usage: run(FLAGS, cfg) without return types