docstr: updates checkpoint from the mmf format to lightning format.
  mmf checkpoint is with keys:
  `model`, `optimizer`, `best_iteration`, `current_iteration`, `current_epoch`, ,
  `num_updates`, `best_update`, `best_metric_value`, `fp16_scaler`, `config`, ,
  `lr_scheduler`, `git/branch`, `git/commit_hash`, `git/commit_author`,
  `git/commit_message`, `git/diff`
docstr_tok: ["updates","checkpoint","from","the","mmf","format","to","lightning","format",".","mmf","checkpoint","is","with","keys",":","`","model","`",",","`","optimizer","`",",","`","best_iteration","`",",","`","current_iteration","`",",","`","current_epoch","`",",",",","`","num_updates","`",",","`","best_update","`",",","`","best_metric_value","`",",","`","fp16_scaler","`",",","`","config","`",",",",","`","lr_scheduler","`",",","`","git\/branch","`",",","`","git\/commit_hash","`",",","`","git\/commit_author","`",",","`","git\/commit_message","`",",","`","git\/diff","`"]
code: def _update_trainer_checkpoint_from_mmf(
      self, checkpoint: Dict[str, Any], model: Any
  ) -> None:
      """updates checkpoint from the mmf format to lightning format.
      mmf checkpoint is with keys:
      `model`, `optimizer`, `best_iteration`, `current_iteration`, `current_epoch`, ,
      `num_updates`, `best_update`, `best_metric_value`, `fp16_scaler`, `config`, ,
      `lr_scheduler`, `git/branch`, `git/commit_hash`, `git/commit_author`,
      `git/commit_message`, `git/diff`
      """
      remove_keys_inplace(
          checkpoint,
          {
              "best_iteration",
              "current_iteration",
              "best_update",
              "best_metric_value",
              "fp16_scaler",
              "config",
              "git/branch",
              "git/commit_hash",
              "git/commit_author",
              "git/commit_message",
              "git/diff",
          },
      )
  
      # update model
      if "model" in checkpoint:
          model_checkpoint = checkpoint.pop("model")
          checkpoint["state_dict"] = model_checkpoint
          self._update_model_format_state_keys(
              checkpoint["state_dict"], model=model
          )
          config = registry.get("config")
          if config.checkpoint.get("resume_pretrained", False):
              self._update_pretrained_state_mapping(
                  checkpoint=checkpoint["state_dict"],
                  model=model,
                  config=config,
              )
      # update trainer progress
      if "optimizer" in checkpoint:
          optimizer = checkpoint.pop("optimizer")
          checkpoint["optimizer_states"] = [optimizer]
      if "lr_scheduler" in checkpoint:
          lr_scheduler = checkpoint.pop("lr_scheduler")
          checkpoint["lr_schedulers"] = [lr_scheduler]
      else:
          # we need to set this if it is not specified bc lightning expects
          # lr_schedulers to be present to resume checkpoint while in mmf, it is
          # not guranteed that lr_schedulers are used and saved in the checkpoint.
          checkpoint["lr_schedulers"] = []
      if "num_updates" in checkpoint:
          global_step = checkpoint.pop("num_updates")
          checkpoint["global_step"] = global_step
      if "current_epoch" in checkpoint:
          epoch = checkpoint.pop("current_epoch")
          checkpoint["epoch"] = epoch
  
file_path: mmf/mmf/utils/checkpoint_updater.py
imports: import logging
  from typing import Any, Dict, Tuple
  import torch
  from mmf.common.registry import registry
label_desc: Use image node_id 3 for calling the MMFToPLCheckpointUpdater obj's underlying member method code with example usage: obj._update_trainer_checkpoint_from_mmf(checkpoint, model) without return types