code: def read_examples(data_dir, data_sign, rel2idx):
      """load data to InputExamples"""
      examples = []
  
      # read src data
      with open(
          os.path.join(data_dir, f"{data_sign}_triples.json"),
          "r",
          encoding="utf-8",
      ) as f:
          data = json.load(f)
          for sample in data:
              text = sample["text"]
              rel2ens = defaultdict(list)
              en_pair_list = []
              re_list = []
  
              for triple in sample["triple_list"]:
                  en_pair_list.append([triple[0], triple[-1]])
                  re_list.append(rel2idx[triple[1]])
                  rel2ens[rel2idx[triple[1]]].append(
                      (triple[0], triple[-1])
                  )
              example = InputExample(
                  text=text,
                  en_pair_list=en_pair_list,
                  re_list=re_list,
                  rel2ens=rel2ens,
              )
              examples.append(example)
      print("InputExamples:", len(examples))
      return examples
  
file_path: DeepKE/src/deepke/triple_extraction/PRGC/dataloader_utils.py
imports: import json
  import random
  from multiprocessing import Pool
  import functools
  import numpy
  from collections import defaultdict
  from itertools import chain
  import os
  from .util import Label2IdxSub, Label2IdxObj
label_desc: Use image node_id 1 for calling a global function with example usage: read_examples(data_dir, data_sign, rel2idx) and returns: examples