class_docstr: TorchRankerAgent implementation of the crossencoder.
  
  It is a standalone Agent. It might be called by the Both Encoder.
class_docstr_tok: ["TorchRankerAgent","implementation","of","the","crossencoder",".","It","is","a","standalone","Agent",".","It","might","be","called","by","the","Both","Encoder","."]
code: def score_candidates(self, batch, cand_vecs, cand_encs=None):
      # concatenate text and candidates (not so easy)
      # unpad and break
      nb_cands = cand_vecs.size()[1]
      size_batch = cand_vecs.size()[0]
      text_vec = batch.text_vec
  
      tokens_context = (
          text_vec.unsqueeze(1)
          .expand(-1, nb_cands, -1)
          .contiguous()
          .view(nb_cands * size_batch, -1)
      )
  
      # remove the start token ["CLS"] from candidates
      tokens_cands = cand_vecs.view(nb_cands * size_batch, -1)
      all_tokens, all_segments = concat_without_padding(
          tokens_context, tokens_cands, self.use_cuda, self.NULL_IDX
      )
      all_mask = all_tokens != self.NULL_IDX
      all_tokens *= all_mask.long()
      scores = self.model(all_tokens, all_segments, all_mask)
      return scores.view(size_batch, nb_cands)
  
file_path: ParlAI/parlai/agents/bert_ranker/cross_encoder_ranker.py
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from parlai.utils.torch import concat_without_padding
  from parlai.core.torch_ranker_agent import TorchRankerAgent
  from parlai.zoo.bert.build import download
  from .bert_dictionary import BertDictionaryAgent
  from .helpers import BertWrapper, BertModel, add_common_args, surround, MODEL_PATH
  import os
label_desc: Use image node_id 4 for calling the CrossEncoderRankerAgent obj's underlying member method code with example usage: obj.score_candidates(batch, cand_vecs, cand_encs) and returns: scores