code: def main(args):
      assert (
          args.config is not None
      ), "No configuration file specified, please set --config"
      cfg = Config(
          args.config,
          learning_rate=args.learning_rate,
          nepochs=args.nepochs,
          batch_size=args.batch_size,
          labeled_ratio=args.labeled_ratio,
          opts=args.opts,
      )
      builder = CPSBuilder(cfg)
  
      utils.show_env_info()
      utils.show_cfg_info(cfg)
      utils.set_seed(args.seed)
      utils.set_device(args.device)
      utils.set_cv2_num_threads(args.num_workers)
  
      # TODO refactor
      # Only support for the DeepLabv3+ model
      if args.data_format == "NHWC":
          if cfg.dic["model"]["type"] != "DeepLabV3P":
              raise ValueError(
                  'The "NHWC" data format only support the DeepLabV3P model!'
              )
          cfg.dic["model"]["data_format"] = args.data_format
          cfg.dic["model"]["backbone"]["data_format"] = args.data_format
          loss_len = len(cfg.dic["loss"]["types"])
          for i in range(loss_len):
              cfg.dic["loss"]["types"][i][
                  "data_format"
              ] = args.data_format
  
      model = utils.convert_sync_batchnorm(builder.model, args.device)
  
      train_dataset = builder.train_dataset
      unsupervised_train_dataset = builder.unsupervised_train_dataset
      mask_genarator = builder.batch_transforms
  
      val_dataset = builder.val_dataset if args.do_eval else None
      optimizer_l = builder.optimizer_l
      optimizer_r = builder.optimizer_r
      loss = builder.loss
  
      train(
          model,
          train_dataset,
          unsupervised_train_dataset=unsupervised_train_dataset,
          mask_genarator=mask_genarator,
          val_dataset=val_dataset,
          optimizer_l=optimizer_l,
          optimizer_r=optimizer_r,
          save_dir=args.save_dir,
          nepochs=cfg.nepochs,
          labeled_ratio=cfg.labeled_ratio,
          batch_size=cfg.batch_size,
          resume_model=args.resume_model,
          save_epoch=args.save_epoch,
          log_iters=args.log_iters,
          num_workers=args.num_workers,
          use_vdl=args.use_vdl,
          losses=loss,
          keep_checkpoint_max=args.keep_checkpoint_max,
          test_config=cfg.test_config,
          profiler_options=args.profiler_options,
      )
  
file_path: PaddleSeg/contrib/CrossPseudoSupervision/train.py
imports: import argparse
  import datasets
  import models
  from cvlibs import Config, CPSBuilder
  from paddleseg.utils import utils
  from core import train
label_desc: Use image node_id 2 for calling a global function with example usage: main(args) without return types