code: def encode_candidate(
      reranker,
      candidate_pool,
      encode_batch_size,
      silent,
      logger,
  ):
      reranker.model.eval()
      device = reranker.device
      # for cand_pool in candidate_pool:
      # logger.info("Encoding candidate pool %s" % src)
      sampler = SequentialSampler(candidate_pool)
      data_loader = DataLoader(
          candidate_pool, sampler=sampler, batch_size=encode_batch_size
      )
      if silent:
          iter_ = data_loader
      else:
          iter_ = tqdm(data_loader)
  
      cand_encode_list = None
      for step, batch in enumerate(iter_):
          cands = batch
          cands = cands.to(device)
          cand_encode = reranker.encode_candidate(cands)
          if cand_encode_list is None:
              cand_encode_list = cand_encode
          else:
              cand_encode_list = torch.cat(
                  (cand_encode_list, cand_encode)
              )
  
      return cand_encode_list
  
file_path: BLINK/scripts/generate_candidates.py
imports: import torch
  from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset
  from elq.biencoder.biencoder import load_biencoder
  import elq.candidate_ranking.utils
  import json
  import sys
  import os
  from tqdm import tqdm
  import argparse
label_desc: Use image node_id 1 for calling a global function with example usage: encode_candidate(reranker, candidate_pool, encode_batch_size, silent, logger) and returns: cand_encode_list