class_docstr: Poly-encoder Agent that ingests image features.
  
  Agent that allows encoding image features and adding or concatenating them to the
  context encoding.
class_docstr_tok: ["Poly-encoder","Agent","that","ingests","image","features",".","Agent","that","allows","encoding","image","features","and","adding","or","concatenating","them","to","the","context","encoding","."]
docstr: Override to account for weights used for image features.
docstr_tok: ["Override","to","account","for","weights","used","for","image","features","."]
code: def load_state_dict(self, state_dict):
      """
      Override to account for weights used for image features.
      """
      for tensor in ["dummy_image_enc", "ones_mask"]:
          key = f"encoder_ctxt.{tensor}"
          if (
              hasattr(self.model.encoder_ctxt, tensor)
              and key not in state_dict
          ):
              state_dict[key] = getattr(self.model.encoder_ctxt, tensor)
      if hasattr(self.model.encoder_ctxt, "image_encoder"):
          for layer_idx, layer in enumerate(
              self.model.encoder_ctxt.image_encoder
          ):
              for tensor in ["weight", "bias"]:
                  key = (
                      f"encoder_ctxt.image_encoder.{layer_idx}.{tensor}"
                  )
                  if hasattr(layer, tensor) and key not in state_dict:
                      state_dict[key] = getattr(layer, tensor)
      super().load_state_dict(state_dict)
  
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 6 for calling the ImagePolyencoderAgent obj's underlying member method code with example usage: obj.load_state_dict(state_dict) without return types