code: def main(cfg):
      cwd = get_original_cwd()
      os.chdir(cwd)
  
      device = torch.device(
          "cuda:0" if torch.cuda.is_available() else "cpu"
      )
  
      config = AutoConfig.from_pretrained(
          cfg.config_name
          if cfg.config_name
          else cfg.model_name_or_path,
          num_labels=cfg.num_class,
      )
      tokenizer = AutoTokenizer.from_pretrained(
          cfg.tokenizer_name
          if cfg.tokenizer_name
          else cfg.model_name_or_path,
      )
  
      Dataset = ReadDataset(
          cfg, cfg.dataset, tokenizer, cfg.max_seq_length
      )
  
      test_file = os.path.join(cfg.data_dir, cfg.test_file)
  
      test_features = Dataset.read(test_file)
  
      model = AutoModel.from_pretrained(
          cfg.model_name_or_path,
          from_tf=bool(".ckpt" in cfg.model_name_or_path),
          config=config,
      )
  
      config.cls_token_id = tokenizer.cls_token_id
      config.sep_token_id = tokenizer.sep_token_id
      config.transformer_type = cfg.transformer_type
  
      set_seed(cfg)
      model = DocREModel(config, cfg, model, num_labels=cfg.num_labels)
  
      model.load_state_dict(torch.load(cfg.load_path)["checkpoint"])
      model.to(device)
      T_features = test_features  # Testing on the test set
      # T_score, T_output = evaluate(cfg, model, T_features, tag="test")
      pred = report(cfg, model, T_features)
      with open("./result.json", "w") as fh:
          json.dump(pred, fh)
  
file_path: DeepKE/example/re/document/predict.py
imports: import os
  import time
  import hydra
  from hydra.utils import get_original_cwd
  import numpy
  import torch
  import ujson
  from torch.utils.data import DataLoader
  from transformers import AutoConfig, AutoModel, AutoTokenizer
  from transformers.optimization import AdamW, get_linear_schedule_with_warmup
  from deepke.relation_extraction.document import *
label_desc: Use image node_id 2 for calling a global function with example usage: main(cfg) without return types