code: def main(cfg):
      cwd = utils.get_original_cwd()
      cfg.cwd = cwd
      print(cfg)
  
      set_seed(cfg.seed)  # set seed, default is 1
      if cfg.save_path is not None:  # make save_path dir
          if not os.path.exists(cfg.save_path):
              os.makedirs(cfg.save_path, exist_ok=True)
      print(cfg)
      label_mapping = {
          label: idx for idx, label in enumerate(LABEL_LIST, 1)
      }
      label_mapping["PAD"] = 0
      data_path, img_path, aux_path = (
          DATA_PATH[cfg.dataset_name],
          IMG_PATH[cfg.dataset_name],
          AUX_PATH[cfg.dataset_name],
      )
      rcnn_img_path = DATA_PATH[cfg.dataset_name]["rcnn_img_path"]
  
      processor = MMPNERProcessor(data_path, cfg)
      train_dataset = MMPNERDataset(
          processor,
          label_mapping,
          img_path,
          aux_path,
          rcnn_img_path,
          max_seq=cfg.max_seq,
          ignore_idx=cfg.ignore_idx,
          aux_size=cfg.aux_size,
          rcnn_size=cfg.rcnn_size,
          mode="train",
          cwd=cwd,
      )
      train_dataloader = DataLoader(
          train_dataset,
          batch_size=cfg.batch_size,
          shuffle=True,
          num_workers=4,
          pin_memory=True,
      )
  
      dev_dataset = MMPNERDataset(
          processor,
          label_mapping,
          img_path,
          aux_path,
          rcnn_img_path,
          max_seq=cfg.max_seq,
          ignore_idx=cfg.ignore_idx,
          aux_size=cfg.aux_size,
          rcnn_size=cfg.rcnn_size,
          mode="dev",
          cwd=cwd,
      )
      dev_dataloader = DataLoader(
          dev_dataset,
          batch_size=cfg.batch_size,
          shuffle=False,
          num_workers=4,
          pin_memory=True,
      )
  
      test_dataset = MMPNERDataset(
          processor,
          label_mapping,
          img_path,
          aux_path,
          rcnn_img_path,
          max_seq=cfg.max_seq,
          ignore_idx=cfg.ignore_idx,
          aux_size=cfg.aux_size,
          rcnn_size=cfg.rcnn_size,
          mode="test",
          cwd=cwd,
      )
      test_dataloader = DataLoader(
          test_dataset,
          batch_size=cfg.batch_size,
          shuffle=False,
          num_workers=4,
          pin_memory=True,
      )
  
      model = IFANERCRFModel(LABEL_LIST, cfg)
  
      trainer = Trainer(
          train_data=train_dataloader,
          dev_data=dev_dataloader,
          test_data=test_dataloader,
          model=model,
          label_map=label_mapping,
          args=cfg,
          logger=logger,
          writer=writer,
      )
      trainer.train()
  
file_path: DeepKE/example/ner/multimodal/run.py
imports: import os
  import hydra
  import torch
  import numpy
  import random
  from hydra import utils
  from torch.utils.data import DataLoader
  from deepke.name_entity_re.multimodal.models.IFA_model import IFANERCRFModel
  from deepke.name_entity_re.multimodal.modules.dataset import MMPNERProcessor, MMPNERDataset
  from deepke.name_entity_re.multimodal.modules.train import Trainer
  import warnings
  import logging
label_desc: Use image node_id 2 for calling a global function with example usage: main(cfg) without return types