def METHOD_NAME(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')
        else:
            raise ValueError(
                "Semi-Supervised Object Detection only support DenseTeacher now."
            )
    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_weights' in cfg and cfg.pretrain_weights:
        trainer.load_weights(cfg.pretrain_weights)
    # training
    trainer.train(FLAGS.eval)