docstr: Get the model name from either `--model` or `--model-file`.
docstr_tok: ["Get","the","model","name","from","either","`","--","model","`","or","`","--","model-file","`","."]
code: def _get_model_name_from_model_file(self, key, opt):
      """
      Get the model name from either `--model` or `--model-file`.
      """
      # try to get model name from model opt file
      model_file = opt.get(key, None)
      optfile = model_file + ".opt"
      new_opt = Opt.load(optfile)
      model = new_opt.get("model", None)
      return model
  
imports: import json
  from copy import deepcopy
  from shutil import copyfile
  import os
  import parlai.utils.logging
  import parlai.core.tod.tod_world
  import parlai.core.tod.tod_agents
  from parlai.core.agents import create_agent
  from parlai.core.metrics import dict_report, aggregate_unnamed_reports
  from parlai.core.opt import Opt
  from parlai.core.params import ParlaiParser
  from parlai.core.script import ParlaiScript, register_script
  from parlai.utils.distributed import is_primary_worker, all_gather_list, is_distributed, get_rank, sync_object, num_workers
  from parlai.utils.io import PathManager
  from parlai.utils.misc import TimeLogger, nice_report
  from parlai.utils.world_logging import WorldLogger
label_desc: Use image node_id 2 for calling the TodWorldParser obj's underlying member method code with example usage: obj._get_model_name_from_model_file(key, opt) and returns: model