class_docstr: Base class for all other agents.
class_docstr_tok: ["Base","class","for","all","other","agents","."]
docstr: Upgrade legacy options when loading an opt file from disk.
  
  This is primarily made available to provide a safe space to handle
  backwards-compatible behavior. For example, perhaps we introduce a
  new option today, which wasn't previously available. We can have the
  argument have a new default, but fall back to the "legacy" compatibility
  behavior if the option doesn't exist.
  
  ``upgrade_opt`` provides an opportunity for such checks for backwards
  compatibility. It is called shortly after loading the opt file from
  disk, and is called before the Agent is initialized.
  
  Other possible examples include:
  
      1. Renaming an option,
      2. Deprecating an old option,
      3. Splitting coupled behavior, etc.
  
  Implementations of ``upgrade_opt`` should conform to high standards,
  due to the risk of these methods becoming complicated and difficult to
  reason about. We recommend the following behaviors:
  
      1. ``upgrade_opt`` should only be used to provide backwards
      compatibility.  Other behavior should find a different location.
      2. Children should always call the parent's ``upgrade_opt`` first.
      3. ``upgrade_opt`` should always warn when an option was overwritten.
      4. Include comments annotating the date and purpose of each upgrade.
      5. Add an integration test which ensures your old work behaves
      appropriately.
  
  :param Opt opt_from_disk:
      The opt file, as loaded from the ``.opt`` file on disk.
  :return:
      The modified options
  :rtype:
      Opt
docstr_tok: ["Upgrade","legacy","options","when","loading","an","opt","file","from","disk",".","This","is","primarily","made","available","to","provide","a","safe","space","to","handle","backwards-compatible","behavior",".","For","example",",","perhaps","we","introduce","a","new","option","today",",","which","was","n't","previously","available",".","We","can","have","the","argument","have","a","new","default",",","but","fall","back","to","the","``","legacy","''","compatibility","behavior","if","the","option","does","n't","exist",".","``","upgrade_opt","``","provides","an","opportunity","for","such","checks","for","backwards","compatibility",".","It","is","called","shortly","after","loading","the","opt","file","from","disk",",","and","is","called","before","the","Agent","is","initialized",".","Other","possible","examples","include",":","1",".","Renaming","an","option",",","2",".","Deprecating","an","old","option",",","3",".","Splitting","coupled","behavior",",","etc",".","Implementations","of","``","upgrade_opt","``","should","conform","to","high","standards",",","due","to","the","risk","of","these","methods","becoming","complicated","and","difficult","to","reason","about",".","We","recommend","the","following","behaviors",":","1",".","``","upgrade_opt","``","should","only","be","used","to","provide","backwards","compatibility",".","Other","behavior","should","find","a","different","location",".","2",".","Children","should","always","call","the","parent","'s","``","upgrade_opt","``","first",".","3",".","``","upgrade_opt","``","should","always","warn","when","an","option","was","overwritten",".","4",".","Include","comments","annotating","the","date","and","purpose","of","each","upgrade",".","5",".","Add","an","integration","test","which","ensures","your","old","work","behaves","appropriately",".",":","param","Opt","opt_from_disk",":","The","opt","file",",","as","loaded","from","the","``",".opt","``","file","on","disk",".",":","return",":","The","modified","options",":","rtype",":","Opt"]
code: def upgrade_opt(cls, opt_from_disk: Opt):
      """
      Upgrade legacy options when loading an opt file from disk.
  
      This is primarily made available to provide a safe space to handle
      backwards-compatible behavior. For example, perhaps we introduce a
      new option today, which wasn't previously available. We can have the
      argument have a new default, but fall back to the "legacy" compatibility
      behavior if the option doesn't exist.
  
      ``upgrade_opt`` provides an opportunity for such checks for backwards
      compatibility. It is called shortly after loading the opt file from
      disk, and is called before the Agent is initialized.
  
      Other possible examples include:
  
          1. Renaming an option,
          2. Deprecating an old option,
          3. Splitting coupled behavior, etc.
  
      Implementations of ``upgrade_opt`` should conform to high standards,
      due to the risk of these methods becoming complicated and difficult to
      reason about. We recommend the following behaviors:
  
          1. ``upgrade_opt`` should only be used to provide backwards
          compatibility.  Other behavior should find a different location.
          2. Children should always call the parent's ``upgrade_opt`` first.
          3. ``upgrade_opt`` should always warn when an option was overwritten.
          4. Include comments annotating the date and purpose of each upgrade.
          5. Add an integration test which ensures your old work behaves
          appropriately.
  
      :param Opt opt_from_disk:
          The opt file, as loaded from the ``.opt`` file on disk.
      :return:
          The modified options
      :rtype:
          Opt
      """
      # 2019-07-11: currently a no-op.
      return opt_from_disk
  
imports: import copy
  from typing import List, Union
  from parlai.core.build_data import modelzoo_path
  from parlai.core.loader import load_agent_module
  from parlai.core.loader import register_agent
  from parlai.core.message import Message
  from parlai.core.opt import Opt
  from parlai.utils.misc import warn_once
  import parlai.utils.logging
  from parlai.utils.io import PathManager
label_desc: Use image node_id 14 for calling the Agent obj's underlying member method code with example usage: obj.upgrade_opt(cls, opt_from_disk) and returns: opt_from_disk