code: def load_dists(all_save_dir, data, split, model, joint_threshold):
      save_dir = "{}/{}_{}_{}_joint{}_top50cands_final_joint".format(
          all_save_dir, data, split, model, joint_threshold
      )
      if not os.path.exists(save_dir):
          save_dir += "_0"
      with open(os.path.join(save_dir, "biencoder_outs.jsonl")) as f:
          examples = f.readlines()
          examples = [json.loads(line) for line in examples]
      biencoder_indices = np.load(
          os.path.join(save_dir, "biencoder_nns.npy"), allow_pickle=True
      )  # corresponds to biencoder_dists
      biencoder_dists = np.load(
          os.path.join(save_dir, "biencoder_dists.npy"),
          allow_pickle=True,
      )
      if os.path.exists(
          os.path.join(save_dir, "biencoder_cand_scores.npy")
      ):
          cand_dists = np.load(
              os.path.join(save_dir, "biencoder_cand_scores.npy"),
              allow_pickle=True,
          )
      else:
          cand_dists = np.load(
              os.path.join(save_dir, "biencoder_cand_dists.npy"),
              allow_pickle=True,
          )
      pred_mention_bounds = np.load(
          os.path.join(save_dir, "biencoder_mention_bounds.npy"),
          allow_pickle=True,
      )
      if os.path.exists(
          os.path.join(save_dir, "biencoder_mention_scores.npy")
      ):
          mention_dists = np.load(
              os.path.join(save_dir, "biencoder_mention_scores.npy"),
              allow_pickle=True,
          )
      else:
          mention_dists = [
              biencoder_dists[i]
              - torch.log_softmax(
                  torch.tensor(cand_dists[i]), 1
              ).numpy()
              for i in range(len(biencoder_dists))
          ]
          # inverse sigmoid
          mention_dists = [
              np.log(md / (1 - md)) for md in mention_dists
          ]
      return (
          examples,
          biencoder_indices,
          biencoder_dists,
          cand_dists,
          pred_mention_bounds,
          mention_dists,
      )
  
file_path: BLINK/scripts/tune_hyperparams_new.py
imports: import json
  import os
  import numpy
  import torch
  from elq.vcg_utils.measures import entity_linking_tp_with_overlap
  from tqdm import tqdm
  from transformers import BertTokenizer
label_desc: Use image node_id 1 for calling a global function with example usage: load_dists(all_save_dir, data, split, model, joint_threshold) and returns: examples,  biencoder_indices,  biencoder_dists,  cand_dists,  pred_mention_bounds,  mention_dists