code: def get_role_list(entities, events, id_map):
      entity_idxs = {
          entity["id"]: (i, entity) for i, entity in enumerate(entities)
      }
      visited = [[0] * len(entities) for _ in range(len(events))]
      role_list = []
      role_list = []
      for i, event in enumerate(events):
          for arg in event["arguments"]:
              entity_idx = entity_idxs[
                  id_map.get(arg["entity_id"], arg["entity_id"])
              ]
  
              # This will automatically remove multi role scenario
              if visited[i][entity_idx[0]] == 0:
                  # ((trigger start, trigger end, trigger type), (argument start, argument end, role type))
                  temp = (
                      (
                          event["trigger"]["start"],
                          event["trigger"]["end"],
                          event["event_type"],
                      ),
                      (
                          entity_idx[1]["start"],
                          entity_idx[1]["end"],
                          arg["role"],
                      ),
                  )
                  role_list.append(temp)
                  visited[i][entity_idx[0]] = 1
      role_list.sort(key=lambda x: (x[0][0], x[1][0]))
      return role_list
  
imports: import json, logging, pickle
  from mimetypes import knownfiles
  from unittest.mock import NonCallableMagicMock
  import torch
  from torch.utils.data import Dataset
  from collections import namedtuple
label_desc: Use image node_id 2 for calling a global function with example usage: get_role_list(entities, events, id_map) and returns: role_list