code: def load_or_generate_candidate_pool(
      tokenizer,
      params,
      logger,
      cand_pool_path,
  ):
      candidate_pool = None
      is_zeshel = params.get("zeshel", None)
      if cand_pool_path is not None:
          # try to load candidate pool from file
          try:
              logger.info("Loading pre-generated candidate pool from: ")
              logger.info(cand_pool_path)
              candidate_pool = torch.load(cand_pool_path)
          except:
              logger.info("Loading failed. Generating candidate pool")
  
      if candidate_pool is None:
          # compute candidate pool from entity list
          entity_desc_list = load_entity_dict(logger, params, is_zeshel)
          candidate_pool = get_candidate_pool_tensor_helper(
              entity_desc_list,
              tokenizer,
              params["max_cand_length"],
              logger,
              is_zeshel,
          )
  
          if cand_pool_path is not None:
              logger.info("Saving candidate pool.")
              torch.save(candidate_pool, cand_pool_path)
  
      return candidate_pool
  
imports: import argparse
  import json
  import logging
  import os
  import torch
  from tqdm import tqdm
  from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset
  from pytorch_transformers.tokenization_bert import BertTokenizer
  from blink.biencoder.biencoder import BiEncoderRanker
  import blink.biencoder.data_process
  import blink.biencoder.nn_prediction
  import blink.candidate_ranking.utils
  from blink.biencoder.zeshel_utils import WORLDS, load_entity_dict_zeshel, Stats
  from blink.common.params import BlinkParser
label_desc: Use image node_id 6 for calling a global function with example usage: load_or_generate_candidate_pool(tokenizer, params, logger, cand_pool_path) and returns: candidate_pool