class_docstr: Poly-encoder Agent.
  
  Equivalent of bert_ranker/polyencoder and biencoder_multiple_output but does not
  rely on an external library (hugging face).
class_docstr_tok: ["Poly-encoder","Agent",".","Equivalent","of","bert_ranker\/polyencoder","and","biencoder_multiple_output","but","does","not","rely","on","an","external","library","(","hugging","face",")","."]
code: def upgrade_opt(cls, opt_from_disk: Opt):
      # call the parent upgrades
      opt_from_disk = super(PolyencoderAgent, cls).upgrade_opt(
          opt_from_disk
      )
  
      polyencoder_attention_keys_value = opt_from_disk.get(
          "polyencoder_attention_keys"
      )
      if polyencoder_attention_keys_value is not None:
          # 2020-02-19 We are deprecating this flag because it was used for a one-time
          # set of experiments and won't be used again. This flag was defaulted to
          # 'context', so throw an exception otherwise.
          if polyencoder_attention_keys_value == "context":
              del opt_from_disk["polyencoder_attention_keys"]
          else:
              raise NotImplementedError(
                  "This --polyencoder-attention-keys mode (found in commit 06f0d9f) is no longer supported!"
              )
  
      return opt_from_disk
  
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 PolyencoderAgent obj's underlying member method code with example usage: obj.upgrade_opt(cls, opt_from_disk) and returns: opt_from_disk