class_docstr: Equivalent of bert_ranker/crossencoder but does not rely on an external library
  (hugging face).
class_docstr_tok: ["Equivalent","of","bert_ranker\/crossencoder","but","does","not","rely","on","an","external","library","(","hugging","face",")","."]
code: def score_candidates(self, batch, cand_vecs, cand_encs=None):
      if cand_encs is not None:
          raise Exception(
              "Candidate pre-computation is impossible on the "
              "crossencoder"
          )
      num_cands_per_sample = cand_vecs.size(1)
      bsz = cand_vecs.size(0)
      text_idx = (
          batch.text_vec.unsqueeze(1)
          .expand(-1, num_cands_per_sample, -1)
          .contiguous()
          .view(num_cands_per_sample * bsz, -1)
      )
      cand_idx = cand_vecs.view(num_cands_per_sample * bsz, -1)
      tokens, segments = concat_without_padding(
          text_idx, cand_idx, self.use_cuda, self.NULL_IDX
      )
      scores = self.model(tokens, segments)
      scores = scores.view(bsz, num_cands_per_sample)
      return scores
  
file_path: ParlAI/parlai/agents/transformer/crossencoder.py
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from .modules import TransformerEncoder
  from parlai.core.torch_ranker_agent import TorchRankerAgent
  from .transformer import TransformerRankerAgent
  from parlai.utils.torch import concat_without_padding
  import torch
label_desc: Use image node_id 5 for calling the CrossencoderAgent obj's underlying member method code with example usage: obj.score_candidates(batch, cand_vecs, cand_encs) and returns: scores