class_docstr: Transformer Ranker Agent.
  
  Implementation of a TorchRankerAgent, where the model is a Transformer
code: def _score(self, output, cands):
      if cands.dim() == 2:
          return torch.matmul(output, cands.t())
      elif cands.dim() == 3:
          return torch.bmm(
              output.unsqueeze(1), cands.transpose(1, 2)
          ).squeeze(1)
      else:
          raise RuntimeError(
              "Unexpected candidate dimensions {}"
              "".format(cands.dim())
          )
  
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from parlai.core.agents import Agent
  from parlai.utils.torch import padded_3d
  from parlai.core.torch_classifier_agent import TorchClassifierAgent
  from parlai.core.torch_ranker_agent import TorchRankerAgent
  from parlai.core.torch_generator_agent import TorchGeneratorAgent
  from parlai.utils.misc import recursive_getattr, warn_once
  from parlai.utils.logging import logging
  from parlai.utils.fsdp import should_use_fsdp
  from .modules import TransformerMemNetModel, TransformerGeneratorModel, TransformerLinearWrapper
  import torch
label_desc: Use image node_id 2 for calling the TransformerRankerAgent obj's underlying member method code with example usage: obj._score(output, cands) and returns: torch, torch