code: def main(configuration, init_distributed=False, predict=False):
      # A reload might be needed for imports
      setup_imports()
      configuration.import_user_dir()
      config = configuration.get_config()
  
      if torch.cuda.is_available():
          torch.cuda.set_device(config.device_id)
          torch.cuda.init()
  
      if init_distributed:
          distributed_init(config)
  
      seed = config.training.seed
      config.training.seed = set_seed(
          seed if seed == -1 else seed + get_rank()
      )
      registry.register("seed", config.training.seed)
  
      config = build_config(configuration)
  
      setup_logger(
          color=config.training.colored_logs,
          disable=config.training.should_not_log,
      )
      logger = logging.getLogger("mmf_cli.run")
      # Log args for debugging purposes
      logger.info(configuration.args)
      logger.info(f"Torch version: {torch.__version__}")
      log_device_names()
      logger.info(f"Using seed {config.training.seed}")
  
      trainer = build_trainer(config)
      trainer.load()
      if predict:
          trainer.inference()
      else:
          trainer.train()
  
file_path: mmf/mmf_cli/run.py
imports: import argparse
  import logging
  import random
  import typing
  import torch
  from mmf.common.registry import registry
  from mmf.utils.build import build_config, build_trainer
  from mmf.utils.configuration import Configuration
  from mmf.utils.distributed import distributed_init, get_rank, infer_init_method, is_xla
  from mmf.utils.env import set_seed, setup_imports
  from mmf.utils.flags import flags
  from mmf.utils.general import log_device_names
  from mmf.utils.logger import setup_logger, setup_very_basic_config
label_desc: Use image node_id 1 for calling a global function with example usage: main(configuration, init_distributed, predict) without return types