code: def _get_model_opts(opt, checkpoint=None):
      """Get `model_opt` to build model, may load from `checkpoint` if any."""
      if checkpoint is not None:
          model_opt = ArgumentParser.ckpt_model_opts(checkpoint["opt"])
          if opt.override_opts:
              logger.info(
                  "Over-ride model option set to true - use with care"
              )
              args = list(opt.__dict__.keys())
              model_args = list(model_opt.__dict__.keys())
              for arg in args:
                  if arg in model_args and getattr(opt, arg) != getattr(
                      model_opt, arg
                  ):
                      logger.info(
                          "Option: %s , value: %s overriding model: %s"
                          % (
                              arg,
                              getattr(opt, arg),
                              getattr(model_opt, arg),
                          )
                      )
              model_opt = opt
          else:
              model_opt = ArgumentParser.ckpt_model_opts(
                  checkpoint["opt"]
              )
              ArgumentParser.update_model_opts(model_opt)
              ArgumentParser.validate_model_opts(model_opt)
              if (
                  opt.tensorboard_log_dir
                  == model_opt.tensorboard_log_dir
                  and hasattr(model_opt, "tensorboard_log_dir_dated")
              ):
                  # ensure tensorboard output is written in the directory
                  # of previous checkpoints
                  opt.tensorboard_log_dir_dated = (
                      model_opt.tensorboard_log_dir_dated
                  )  # noqa: E501
              # Override checkpoint's update_embeddings as it defaults to false
              model_opt.update_vocab = opt.update_vocab
              # Override checkpoint's freezing settings as it defaults to false
              model_opt.freeze_encoder = opt.freeze_encoder
              model_opt.freeze_decoder = opt.freeze_decoder
      else:
          model_opt = opt
      return model_opt
  
imports: import torch
  import sys
  from onmt.utils.logging import init_logger, logger
  from onmt.utils.parse import ArgumentParser
  from onmt.constants import CorpusTask
  from onmt.transforms import make_transforms, save_transforms, get_specials, get_transforms_cls
  from onmt.inputters import build_vocab
  from onmt.inputters.inputter import dict_to_vocabs, vocabs_to_dict
  from onmt.inputters.dynamic_iterator import build_dynamic_dataset_iter
  from onmt.inputters.text_corpus import save_transformed_sample
  from onmt.model_builder import build_model
  from onmt.models.model_saver import load_checkpoint
  from onmt.utils.optimizers import Optimizer
  from onmt.utils.misc import set_random_seed
  from onmt.trainer import build_trainer
  from onmt.models import build_model_saver
  from onmt.modules.embeddings import prepare_pretrained_embeddings
label_desc: Use image node_id 4 for calling a global function with example usage: _get_model_opts(opt, checkpoint) and returns: model_opt