code: def __init__(self, params, shared=None):
      super(BiEncoderRanker, self).__init__()
      self.params = params
      self.device = torch.device(
          "cuda"
          if torch.cuda.is_available() and not params["no_cuda"]
          else "cpu"
      )
      self.n_gpu = torch.cuda.device_count()
      # init tokenizer
      self.NULL_IDX = 0
      self.START_TOKEN = "[CLS]"
      self.END_TOKEN = "[SEP]"
      self.tokenizer = BertTokenizer.from_pretrained(
          params["bert_model"], do_lower_case=params["lowercase"]
      )
      # init model
      self.build_model()
      model_path = params.get("path_to_model", None)
      if model_path is not None:
          self.load_model(
              model_path,
              cand_enc_only=params.get("load_cand_enc_only", False),
          )
      self.model = self.model.to(self.device)
      self.data_parallel = params.get("data_parallel")
      if self.data_parallel:
          self.model = torch.nn.DataParallel(self.model)
  
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 1 to create a new BiEncoderRanker object from inherited base classes: torch.nn with example: obj = BiEncoderRanker(params, shared)