class_docstr: A Bi Encoder followed by a Cross Encoder.
  
  Although it's trainable by itself, I'd recommend training the crossencoder and the
  biencoder separately which can be done in parallel or sequentially and thus
  requiring less memory on the GPU.
class_docstr_tok: ["A","Bi","Encoder","followed","by","a","Cross","Encoder",".","Although","it","'s","trainable","by","itself",",","I","'d","recommend","training","the","crossencoder","and","the","biencoder","separately","which","can","be","done","in","parallel","or","sequentially","and","thus","requiring","less","memory","on","the","GPU","."]
code: def __init__(self, opt, shared=None):
      opt["lr_scheduler"] = "none"
      self.path_biencoder = opt.get("biencoder_model_file", None)
      if self.path_biencoder is None:
          self.path_biencoder = opt["model_file"] + "_bi"
      self.path_crossencoder = opt.get("crossencoder_model_file", None)
      if self.path_crossencoder is None:
          self.path_crossencoder = opt["model_file"] + "_cross"
      self.top_n_bi = opt["biencoder_top_n"]
  
      super().__init__(opt, shared)
      self.NULL_IDX = self.dict.pad_idx
      self.START_IDX = self.dict.start_idx
      self.END_IDX = self.dict.end_idx
      if shared is None:
          opt_biencoder = dict(opt)
          opt_biencoder["model_file"] = self.path_biencoder
          self.biencoder = BiEncoderRankerAgent(opt_biencoder)
          opt_crossencoder = dict(opt)
          opt_crossencoder["model_file"] = self.path_crossencoder
          opt_crossencoder["batchsize"] = opt["batchsize"]
          opt_crossencoder["eval_candidates"] = "inline"
          if opt["crossencoder_batchsize"] != -1:
              opt_crossencoder["batchsize"] = opt[
                  "crossencoder_batchsize"
              ]
          self.crossencoder_batchsize = opt_crossencoder["batchsize"]
          self.crossencoder = CrossEncoderRankerAgent(opt_crossencoder)
  
file_path: ParlAI/parlai/agents/bert_ranker/both_encoder_ranker.py
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from .bert_dictionary import BertDictionaryAgent
  from .bi_encoder_ranker import BiEncoderRankerAgent
  from .cross_encoder_ranker import CrossEncoderRankerAgent
  from .helpers import add_common_args
  from parlai.core.torch_agent import TorchAgent, Output, Batch
label_desc: Use image node_id 2 to create a new BothEncoderRankerAgent object from inherited base classes: TorchAgent with example: obj = BothEncoderRankerAgent(opt, shared)