class_docstr: Poly-encoder model with image features.
  
  Model that allows encoding image features and adding or concatenating them to the
  context encoding.
class_docstr_tok: ["Poly-encoder","model","with","image","features",".","Model","that","allows","encoding","image","features","and","adding","or","concatenating","them","to","the","context","encoding","."]
docstr: Return encoder that allows for image features to be passed in, given options.
  
  :param opt:
      opt dict
  :param dict:
      dictionary agent
  :param null_idx:
      null/pad index into dict
  :param reduction_type: only used for compatibility with the superclass method
  :param for_context:
      whether this is the context encoder (as opposed to the candidate encoder)
  :return:
      either a TransformerEncoder or a ContextWithImageEncoder, initialized
      correctly
docstr_tok: ["Return","encoder","that","allows","for","image","features","to","be","passed","in",",","given","options",".",":","param","opt",":","opt","dict",":","param","dict",":","dictionary","agent",":","param","null_idx",":","null\/pad","index","into","dict",":","param","reduction_type",":","only","used","for","compatibility","with","the","superclass","method",":","param","for_context",":","whether","this","is","the","context","encoder","(","as","opposed","to","the","candidate","encoder",")",":","return",":","either","a","TransformerEncoder","or","a","ContextWithImageEncoder",",","initialized","correctly"]
code: def get_encoder(
      self, opt, dict_, null_idx, reduction_type, for_context: bool
  ):
      """
      Return encoder that allows for image features to be passed in, given options.
  
      :param opt:
          opt dict
      :param dict:
          dictionary agent
      :param null_idx:
          null/pad index into dict
      :param reduction_type: only used for compatibility with the superclass method
      :param for_context:
          whether this is the context encoder (as opposed to the candidate encoder)
      :return:
          either a TransformerEncoder or a ContextWithImageEncoder, initialized
          correctly
      """
      if for_context:
          if reduction_type is not None:
              raise NotImplementedError(
                  "No encoder output reductions supported!"
              )
          embeddings = self._get_embeddings(
              dict_=dict_,
              null_idx=null_idx,
              embedding_size=opt["embedding_size"],
          )
          return ContextWithImageEncoder(
              opt=opt,
              vocabulary_size=len(dict_),
              embedding=embeddings,
              padding_idx=null_idx,
              image_encoder_num_layers=opt["image_encoder_num_layers"],
              image_features_dim=opt["image_features_dim"],
              image_combination_mode=opt["image_combination_mode"],
              n_image_tokens=opt["n_image_tokens"],
          )
      else:
          # The candidate encoder is the same as for PolyEncoderModule
          return super().get_encoder(
              opt=opt,
              dict_=dict_,
              null_idx=null_idx,
              reduction_type=reduction_type,
              for_context=for_context,
          )
  
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from typing import Any, Dict
  import torch
  from parlai.agents.image_seq2seq.modules import ContextWithImageEncoder
  from parlai.agents.transformer.polyencoder import PolyencoderAgent, PolyEncoderModule
  from parlai.core.torch_agent import Batch
  from parlai.core.torch_image_agent import TorchImageAgent
  from parlai.utils.misc import warn_once
label_desc: Use image node_id 1 for calling the ImagePolyencoderModule obj's underlying member method code with example usage: obj.get_encoder(opt, dict_, null_idx, reduction_type, for_context) and returns: ContextWithImageEncoder, super