code: def encode_candidate(self, cands):
      token_idx_cands, segment_idx_cands, mask_cands = to_bert_input(
          cands, self.NULL_IDX
      )
      _, embedding_cands = self.model(
          None,
          None,
          None,
          token_idx_cands,
          segment_idx_cands,
          mask_cands,
      )
      return embedding_cands
  
imports: import os
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from tqdm import tqdm
  from collections import OrderedDict
  from pytorch_transformers.modeling_bert import BertPreTrainedModel, BertConfig, BertModel
  from pytorch_transformers.tokenization_bert import BertTokenizer
  from elq.common.ranker_base import BertEncoder, get_model_obj
  from blink.common.optimizer import get_bert_optimizer
  from elq.biencoder.allennlp_span_utils import batched_span_select, batched_index_select
  from elq.biencoder.utils import batch_reshape_mask_left
label_desc: Use image node_id 7 for calling the BiEncoderRanker obj's underlying member method code with example usage: obj.encode_candidate(cands) and returns: embedding_cands