code: def _run_biencoder(
      biencoder, dataloader, candidate_encoding, top_k=100, indexer=None
  ):
      biencoder.model.eval()
      labels = []
      nns = []
      all_scores = []
      for batch in tqdm(dataloader):
          context_input, _, label_ids = batch
          with torch.no_grad():
              if indexer is not None:
                  context_encoding = biencoder.encode_context(
                      context_input
                  ).numpy()
                  context_encoding = np.ascontiguousarray(
                      context_encoding
                  )
                  scores, indicies = indexer.search_knn(
                      context_encoding, top_k
                  )
              else:
                  scores = biencoder.score_candidate(
                      context_input,
                      None,
                      cand_encs=candidate_encoding,  # .to(device)
                  )
                  scores, indicies = scores.topk(top_k)
                  scores = scores.data.numpy()
                  indicies = indicies.data.numpy()
  
          labels.extend(label_ids.data.numpy())
          nns.extend(indicies)
          all_scores.extend(scores)
      return labels, nns, all_scores
  
imports: import argparse
  import json
  import sys
  from tqdm import tqdm
  import logging
  import torch
  import numpy
  from colorama import init
  from termcolor import colored
  import blink.ner
  from torch.utils.data import DataLoader, SequentialSampler, TensorDataset
  from blink.biencoder.biencoder import BiEncoderRanker, load_biencoder
  from blink.crossencoder.crossencoder import CrossEncoderRanker, load_crossencoder
  from blink.biencoder.data_process import process_mention_data, get_candidate_representation
  import blink.candidate_ranking.utils
  from blink.crossencoder.train_cross import modify, evaluate
  from blink.crossencoder.data_process import prepare_crossencoder_data
  from blink.indexer.faiss_indexer import DenseFlatIndexer, DenseHNSWFlatIndexer
label_desc: Use image node_id 9 for calling a global function with example usage: _run_biencoder(biencoder, dataloader, candidate_encoding, top_k, indexer) and returns: labels,  nns,  all_scores