class_docstr: Poly-encoder model.
  
  See https://arxiv.org/abs/1905.01969 for more details
class_docstr_tok: ["Poly-encoder","model",".","See","https",":","\/\/arxiv.org\/abs\/1905.01969","for","more","details"]
docstr: Return encoder, given options.
  
  :param opt:
      opt dict
  :param dict:
      dictionary agent
  :param null_idx:
      null/pad index into dict
  :param reduction_type:
      reduction type for the encoder
  :param for_context:
      whether this is the context encoder (as opposed to the candidate encoder).
      Useful for subclasses.
  :return:
      a TransformerEncoder, initialized correctly
docstr_tok: ["Return","encoder",",","given","options",".",":","param","opt",":","opt","dict",":","param","dict",":","dictionary","agent",":","param","null_idx",":","null\/pad","index","into","dict",":","param","reduction_type",":","reduction","type","for","the","encoder",":","param","for_context",":","whether","this","is","the","context","encoder","(","as","opposed","to","the","candidate","encoder",")",".","Useful","for","subclasses",".",":","return",":","a","TransformerEncoder",",","initialized","correctly"]
code: def get_encoder(
      self, opt, dict_, null_idx, reduction_type, for_context: bool
  ):
      """
      Return encoder, given options.
  
      :param opt:
          opt dict
      :param dict:
          dictionary agent
      :param null_idx:
          null/pad index into dict
      :param reduction_type:
          reduction type for the encoder
      :param for_context:
          whether this is the context encoder (as opposed to the candidate encoder).
          Useful for subclasses.
      :return:
          a TransformerEncoder, initialized correctly
      """
      embeddings = self._get_embeddings(
          dict_=dict_,
          null_idx=null_idx,
          embedding_size=opt["embedding_size"],
      )
      return TransformerEncoder(
          opt=opt,
          embedding=embeddings,
          vocabulary_size=len(dict_),
          padding_idx=null_idx,
          reduction_type=reduction_type,
      )
  
imports: from parlai.core.params import ParlaiParser
  from typing import Any, Dict, Optional, Tuple
  import torch
  from parlai.core.opt import Opt
  from parlai.core.torch_ranker_agent import TorchRankerAgent
  from parlai.core.torch_agent import Batch
  from parlai.utils.misc import recursive_getattr
  from parlai.utils.logging import logging
  from .biencoder import AddLabelFixedCandsTRA
  from .modules import BasicAttention, MultiHeadAttention, TransformerEncoder
  from .transformer import TransformerRankerAgent
label_desc: Use image node_id 2 for calling the PolyEncoderModule obj's underlying member method code with example usage: obj.get_encoder(opt, dict_, null_idx, reduction_type, for_context) and returns: TransformerEncoder