code: def convert_data(params, entity_dict, entity_map, mode):
      if mode == "valid":
          fname = os.path.join(params.mention_path, "val.json")
      else:
          fname = os.path.join(params.mention_path, mode + ".json")
  
      fout = open(
          os.path.join(params.output_path, mode + ".jsonl"), "wt"
      )
      cnt = 0
      max_tok = 128
      with open(fname, "rt") as f:
          for line in f:
              cnt += 1
              line = line.rstrip()
              item = json.loads(line)
              mention = item["text"].lower()
              src = item["corpus"]
              label_doc_id = item["label_document_id"]
              orig_doc_id = item["context_document_id"]
              start = item["start_index"]
              end = item["end_index"]
  
              # add context around the mention as well
              orig_id = entity_map[src][orig_doc_id]
              text = entity_dict[src][orig_id]["text"].lower()
              tokens = text.split(" ")
  
              assert mention == " ".join(tokens[start : end + 1])
              tokenized_query = mention
  
              mention_context_left = tokens[
                  max(0, start - max_tok) : start
              ]
              mention_context_right = tokens[
                  end + 1 : min(len(tokens), end + max_tok + 1)
              ]
  
              # entity info
              k = entity_map[src][label_doc_id]
              ent_title = entity_dict[src][k]["title"]
              ent_text = entity_dict[src][k]["text"]
  
              example = {}
              example["context_left"] = " ".join(mention_context_left)
              example["context_right"] = " ".join(mention_context_right)
              example["mention"] = mention
              example["label"] = ent_text
              example["label_id"] = k
              example["label_title"] = ent_title
              example["world"] = src
              fout.write(json.dumps(example))
              fout.write("\n")
  
      fout.close()
  
file_path: BLINK/examples/zeshel/create_BLINK_zeshel_data.py
imports: import argparse
  import json
  import logging
  import os
  import random
  import time
  import torch
  from datetime import timedelta
label_desc: Use image node_id 2 for calling a global function with example usage: convert_data(params, entity_dict, entity_map, mode) without return types