code: def main_worker(
      gpu, port, ngpus_per_node, config, buffer_dict, exp_name, mode
  ):
      torch.distributed.init_process_group(
          backend="nccl",
          init_method="tcp://127.0.0.1:" + port,
          world_size=ngpus_per_node,
          rank=gpu,
      )
  
      # Apply config to wandb
      if gpu == 0 and config["wandb_opt"]:
          wandb.init(
              project="craft-stage2", entity="user_name", name=exp_name
          )
          wandb.config.update(config)
  
      batch_size = int(config["train"]["batch_size"] / ngpus_per_node)
      config["train"]["batch_size"] = batch_size
      config = DotDict(config)
  
      # Start train
      trainer = Trainer(config, gpu, mode)
      trainer.train(buffer_dict)
  
      if gpu == 0:
          if config["wandb_opt"]:
              wandb.finish()
  
      torch.distributed.barrier()
      torch.distributed.destroy_process_group()
  
imports: import argparse
  import os
  import shutil
  import time
  import multiprocessing
  import yaml
  import numpy
  import torch
  import torch.nn
  import torch.optim
  import wandb
  from config.load_config import load_yaml, DotDict
  from data.dataset import SynthTextDataSet, CustomDataset
  from loss.mseloss import Maploss_v2, Maploss_v3
  from model.craft import CRAFT
  from eval import main_eval
  from metrics.eval_det_iou import DetectionIoUEvaluator
  from utils.util import copyStateDict, save_parser
label_desc: Use image node_id 2 for calling a global function with example usage: main_worker(gpu, port, ngpus_per_node, config, buffer_dict, exp_name, mode) without return types