code: def cal_scores(gold_triggers, pred_triggers, gold_roles, pred_roles):
      # tri_id
      gold_tri_id_num, pred_tri_id_num, match_tri_id_num = 0, 0, 0
      for gold_trigger, pred_trigger in zip(
          gold_triggers, pred_triggers
      ):
          gold_set = set([(t[0], t[1]) for t in gold_trigger])
          pred_set = set([(t[0], t[1]) for t in pred_trigger])
          gold_tri_id_num += len(gold_set)
          pred_tri_id_num += len(pred_set)
          match_tri_id_num += len(gold_set & pred_set)
  
      # tri_cls
      gold_tri_cls_num, pred_tri_cls_num, match_tri_cls_num = 0, 0, 0
      for gold_trigger, pred_trigger in zip(
          gold_triggers, pred_triggers
      ):
          gold_set = set(gold_trigger)
          pred_set = set(pred_trigger)
          gold_tri_cls_num += len(gold_set)
          pred_tri_cls_num += len(pred_set)
          match_tri_cls_num += len(gold_set & pred_set)
  
      # arg_id
      gold_arg_id_num, pred_arg_id_num, match_arg_id_num = 0, 0, 0
      for gold_role, pred_role in zip(gold_roles, pred_roles):
          gold_set = set([(r[0][2],) + r[1][:-1] for r in gold_role])
          pred_set = set([(r[0][2],) + r[1][:-1] for r in pred_role])
  
          gold_arg_id_num += len(gold_set)
          pred_arg_id_num += len(pred_set)
          match_arg_id_num += len(gold_set & pred_set)
  
      # arg_cls
      gold_arg_cls_num, pred_arg_cls_num, match_arg_cls_num = 0, 0, 0
      for gold_role, pred_role in zip(gold_roles, pred_roles):
          gold_set = set([(r[0][2],) + r[1] for r in gold_role])
          pred_set = set([(r[0][2],) + r[1] for r in pred_role])
  
          gold_arg_cls_num += len(gold_set)
          pred_arg_cls_num += len(pred_set)
          match_arg_cls_num += len(gold_set & pred_set)
  
      scores = {
          "tri_id": (gold_tri_id_num, pred_tri_id_num, match_tri_id_num)
          + compute_f1(
              gold_tri_id_num, pred_tri_id_num, match_tri_id_num
          ),
          "tri_cls": (
              gold_tri_cls_num,
              pred_tri_cls_num,
              match_tri_cls_num,
          )
          + compute_f1(
              gold_tri_cls_num, pred_tri_cls_num, match_tri_cls_num
          ),
          "arg_id": (gold_arg_id_num, pred_arg_id_num, match_arg_id_num)
          + compute_f1(
              gold_arg_id_num, pred_arg_id_num, match_arg_id_num
          ),
          "arg_cls": (
              gold_arg_cls_num,
              pred_arg_cls_num,
              match_arg_cls_num,
          )
          + compute_f1(
              gold_arg_cls_num, pred_arg_cls_num, match_arg_cls_num
          ),
      }
  
      return scores
  
file_path: DeepKE/example/ee/standard/degree/predict.py
imports: import os, sys, json, logging, pprint, tqdm
  import numpy
  import torch
  from torch.utils.data import DataLoader
  from transformers import AutoTokenizer
  from deepke.event_extraction.standard.degree.model import GenerativeModel
  from deepke.event_extraction.standard.degree.data import GenDataset, EEDataset
  from deepke.event_extraction.standard.degree.utils import compute_f1
  from deepke.event_extraction.standard.degree.template_generate_ace import *
  import ipdb
  import hydra
  from hydra import utils
  from omegaconf import OmegaConf, open_dict
label_desc: Use image node_id 3 for calling a global function with example usage: cal_scores(gold_triggers, pred_triggers, gold_roles, pred_roles) and returns: scores