class_docstr: Transformer Ranker Agent.
  
  Implementation of a TorchRankerAgent, where the model is a Transformer
docstr: Add command-line arguments specifically for this agent.
docstr_tok: ["Add","command-line","arguments","specifically","for","this","agent","."]
code: def add_cmdline_args(
      cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
  ) -> ParlaiParser:
      """
      Add command-line arguments specifically for this agent.
      """
      super().add_cmdline_args(parser, partial_opt=partial_opt)
      agent = parser.add_argument_group("Transformer Arguments")
      add_common_cmdline_args(agent)
      # memory and knowledge arguments
      agent.add_argument(
          "--use-memories",
          type="bool",
          default=False,
          help="use memories: must implement the function "
          "`_vectorize_memories` to use this",
      )
      agent.add_argument(
          "--wrap-memory-encoder",
          type="bool",
          default=False,
          help="wrap memory encoder with MLP",
      )
      agent.add_argument(
          "--memory-attention",
          type=str,
          default="sqrt",
          choices=["cosine", "dot", "sqrt"],
          help="similarity for basic attention mechanism "
          "when using transformer to encode memories",
      )
      # model specific arguments
      agent.add_argument(
          "--normalize-sent-emb", type="bool", default=False
      )
      agent.add_argument("--share-encoders", type="bool", default=True)
      parser.add_argument(
          "--share-word-embeddings",
          type="bool",
          default=True,
          help="Share word embeddings table for candidate and context"
          "in the memory network",
      )
      agent.add_argument(
          "--learn-embeddings",
          type="bool",
          default=True,
          help="learn embeddings",
      )
      agent.add_argument(
          "--data-parallel",
          type="bool",
          default=False,
          help="use model in data parallel, requires " "multiple gpus",
      )
      agent.add_argument(
          "--reduction-type",
          type=str,
          default="mean",
          choices=["first", "max", "mean"],
          help="Type of reduction at the end of transformer",
      )
  
      parser.set_defaults(
          learningrate=0.0001, optimizer="adamax", truncate=1024
      )
      cls.dictionary_class().add_cmdline_args(
          parser, partial_opt=partial_opt
      )
  
      return agent
  
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 1 for calling the TransformerRankerAgent obj's underlying member method code with example usage: obj.add_cmdline_args(cls, parser, partial_opt) and returns: agent