code: def __init__(self, config):
      self.config = config
  
      self.data_dir = config["data_dir"]
      self.dataset = config["dataset"]
  
      # Get tensorized samples
      cache_path = self.get_cache_path()
      if os.path.exists(cache_path):
          # Load cached tensors if exists
          with open(cache_path, "rb") as f:
              self.tensor_samples, self.stored_info = pickle.load(f)
              logger.info(
                  f"Loaded tensorized examples from cache: {cache_path}"
              )
      else:
          # Generate tensorized samples
          self.tensor_samples = {}
          tensorizer = Tensorizer(self.config)
          suffix = f'{self.config["plm_tokenizer_name"]}.jsonlines'
  
          if self.dataset == "conll04":
              paths = {
                  "trn": join(self.data_dir, f"train_dev.{suffix}"),
                  "dev": join(self.data_dir, f"dev.{suffix}"),
                  "tst": join(self.data_dir, f"test.{suffix}"),
              }
          elif self.dataset == "CMeIE":
              paths = {
                  "trn": join(self.data_dir, f"train.{suffix}"),
                  "dev": join(self.data_dir, f"dev.{suffix}"),
                  "tst": join(self.data_dir, f"test.{suffix}"),
              }
  
          for split, path in paths.items():
              logger.info(
                  f"Tensorizing examples from {path}; results will be cached in {cache_path}"
              )
              is_training = split == "trn"
  
              with open(path, "r") as f:
                  samples = json.loads(f.read())
              tensor_samples = [
                  tensorizer.tensorize_example(sample, is_training)
                  for sample in samples
              ]
              print(split, len(tensor_samples))
  
              self.tensor_samples[split] = EREDataset(
                  sorted(
                      [
                          (doc_key, tensor)
                          for doc_key, tensor in tensor_samples
                      ],
                      key=lambda x: -x[1]["input_ids"].size(0),
                  )
              )
          self.stored_info = tensorizer.stored_info
          # Cache tensorized samples
          with open(cache_path, "wb") as f:
              pickle.dump((self.tensor_samples, self.stored_info), f)
  
imports: import sys
  import os
  import numpy
  import random
  from transformers import T5Tokenizer
  from os.path import join
  import json
  import copy
  import pickle
  import logging
  import torch
  from torch.utils.data import Dataset, DataLoader
  import torch.nn.functional
  import util
label_desc: Use image node_id 1 to create a new EREDataProcessor object from inherited base classes: object with example: obj = EREDataProcessor(config)