code: def data_process(raw_data, task="trigger", mode="train"):
      output = (
          ["text_a\tlabel\tindex"]
          if task == "trigger"
          else ["text_a\tlabel\ttrigger_tag\tindex"]
      )
  
      for idx, line in enumerate(
          tqdm(raw_data, desc="processing " + mode + " " + task)
      ):
          line = json.loads(line)
  
          text_a = line["tokens"]
          if task == "trigger":
              trigger_labels = ["O"] * len(text_a)
              for mention in line["event_mentions"]:
                  event_type = mention["event_type"]
                  trigger_start = mention["trigger"]["start"]
                  trigger_end = mention["trigger"]["end"]
                  trigger = mention["trigger"]["text"]
                  trigger_labels = label_data(
                      trigger_labels,
                      trigger_start,
                      trigger_end - trigger_start,
                      event_type,
                      task,
                  )
              assert len(text_a) == len(trigger_labels)
              output.append(
                  "{}\t{}\t{}".format(
                      " ".join(text_a),
                      " ".join(trigger_labels),
                      str(idx),
                  )
              )
          elif task == "role":
              # for negative samples
              if len(line["event_mentions"]) == 0:
                  output.append(
                      "{}\t{}\t{}\t{}".format(
                          " ".join(text_a),
                          " ".join(["O"] * len(text_a)),
                          " ".join(["O"] * len(text_a)),
                          str(idx),
                      )
                  )
                  continue
              entity_mention = line["entity_mentions"]
              entity_id2mention = {
                  mention["id"]: mention for mention in entity_mention
              }
  
              for mention in line["event_mentions"]:
                  trigger_labels = ["O"] * len(text_a)
                  event_type = mention["event_type"]
                  trigger_start = mention["trigger"]["start"]
                  trigger_end = mention["trigger"]["end"]
                  trigger = mention["trigger"]["text"]
                  trigger_labels = label_data(
                      trigger_labels,
                      trigger_start,
                      trigger_end - trigger_start,
                      event_type,
                  )
  
                  role_labels = ["O"] * len(text_a)
                  for arg in mention["arguments"]:
                      role_type = arg["role"]
                      argument = arg["text"]
                      role_entity = entity_id2mention[arg["entity_id"]]
                      role_start = role_entity["start"]
                      role_end = role_entity["end"]
                      role_labels = label_data(
                          role_labels,
                          role_start,
                          role_end - role_start,
                          role_type,
                          task,
                      )
                  assert (
                      len(text_a)
                      == len(role_labels)
                      == len(trigger_labels)
                  )
                  output.append(
                      "{}\t{}\t{}\t{}".format(
                          " ".join(text_a),
                          " ".join(role_labels),
                          " ".join(trigger_labels),
                          str(idx),
                      )
                  )
  
      print(len(output))
      return output
  
file_path: DeepKE/example/ee/standard/data/ACE/preprocess/preprocessing/process_bertcrf.py
imports: import argparse
  import json
  from collections import Counter, defaultdict
  import os, sys
  from tqdm import tqdm
label_desc: Use image node_id 4 for calling a global function with example usage: data_process(raw_data, task, mode) and returns: output