code: def main(cfg):
      cwd = get_original_cwd()
      os.chdir(cwd)
      params = util.Params(cfg.ex_index, cfg.corpus_type)
      setattr(params, "root_path", cwd)
      setattr(
          params,
          "data_dir",
          os.path.join(params.root_path, f"data/{cfg.corpus_type}"),
      )
      setattr(
          params,
          "ex_dir",
          os.path.join(
              params.root_path, f"experiments/ex{cfg.ex_index}"
          ),
      )
      setattr(
          params,
          "model_dir",
          os.path.join(params.root_path, f"model/ex{cfg.ex_index}"),
      )
      setattr(
          params,
          "bert_model_dir",
          os.path.join(
              params.root_path, f"pretrain_models", cfg.pretrain_model
          ),
      )
      setattr(
          params,
          "rel2idx",
          json.load(
              open(
                  os.path.join(params.data_dir, "rel2id.json"),
                  "r",
                  encoding="utf-8",
              )
          )[-1],
      )
      setattr(params, "rel_num", len(params.rel2idx))
      for key, value in cfg.items():
          setattr(params, key, value)
  
      ex_params = {
          "ensure_corres": cfg.ensure_corres,
          "ensure_rel": cfg.ensure_rel,
          "num_negs": cfg.num_negs,
          "emb_fusion": cfg.emb_fusion,
      }
  
      if params.multi_gpu:
          params.device = torch.device(
              "cuda" if torch.cuda.is_available() else "cpu"
          )
          n_gpu = torch.cuda.device_count()
          params.n_gpu = n_gpu
      else:
          torch.cuda.set_device(params.device_id)
          print("current device:", torch.cuda.current_device())
          params.n_gpu = n_gpu = 1
  
      # Set the random seed for reproducible experiments
      random.seed(params.seed)
      torch.manual_seed(params.seed)
      params.seed = params.seed
      if n_gpu > 0:
          torch.cuda.manual_seed_all(params.seed)
  
      # Set the logger
      util.set_logger(
          save=True, log_path=os.path.join(params.ex_dir, "train.log")
      )
      logging.info(f"Model type:")
      logging.info("device: {}".format(params.device))
  
      logging.info("Load pre-train model weights...")
      bert_config = BertConfig.from_json_file(
          os.path.join(params.bert_model_dir, "bert_config.json")
      )
      model = BertForRE.from_pretrained(
          config=bert_config,
          pretrained_model_name_or_path=params.bert_model_dir,
          params=params,
      )
      logging.info("-done")
  
      # Train and evaluate the model
      logging.info(
          "Starting training for {} epoch(s)".format(params.epoch_num)
      )
      train_and_evaluate(model, params, ex_params, params.restore_file)
  
file_path: DeepKE/example/triple/PRGC/run.py
imports: import os
  import hydra
  from hydra.utils import get_original_cwd
  import torch
  from transformers import BertConfig
  import random
  import logging
  from tqdm import trange
  import argparse
  import wandb
  from deepke.triple_extraction.PRGC import *
label_desc: Use image node_id 3 for calling a global function with example usage: main(cfg) without return types