code: def __init__(self, params, shared=None):
      super(CrossEncoderRanker, 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()
  
      if params.get("roberta"):
          self.tokenizer = RobertaTokenizer.from_pretrained(
              params["bert_model"],
          )
      else:
          self.tokenizer = BertTokenizer.from_pretrained(
              params["bert_model"], do_lower_case=params["lowercase"]
          )
  
      special_tokens_dict = {
          "additional_special_tokens": [
              ENT_START_TAG,
              ENT_END_TAG,
              ENT_TITLE_TAG,
          ],
      }
      self.tokenizer.add_special_tokens(special_tokens_dict)
      self.NULL_IDX = self.tokenizer.pad_token_id
      self.START_TOKEN = self.tokenizer.cls_token
      self.END_TOKEN = self.tokenizer.sep_token
  
      # init model
      self.build_model()
      if params["path_to_model"] is not None:
          self.load_model(params["path_to_model"])
  
      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 collections import OrderedDict
  from tqdm import tqdm
  from pytorch_transformers.modeling_utils import CONFIG_NAME, WEIGHTS_NAME
  from pytorch_transformers.modeling_bert import BertPreTrainedModel, BertConfig, BertModel
  from pytorch_transformers.modeling_roberta import RobertaConfig, RobertaModel
  from pytorch_transformers.tokenization_bert import BertTokenizer
  from pytorch_transformers.tokenization_roberta import RobertaTokenizer
  from blink.common.ranker_base import BertEncoder, get_model_obj
  from blink.common.optimizer import get_bert_optimizer
  from blink.common.params import ENT_START_TAG, ENT_END_TAG, ENT_TITLE_TAG
label_desc: Use image node_id 1 to create a new CrossEncoderRanker object from inherited base classes: torch.nn with example: obj = CrossEncoderRanker(params, shared)