docstr: Generates a path for saving model which can also be used for resuming
  from a checkpoint.
code: def __init__(self, trainer):
      """
      Generates a path for saving model which can also be used for resuming
      from a checkpoint.
      """
      self.trainer = trainer
  
      self.config = self.trainer.config
      self.save_dir = get_mmf_env(key="save_dir")
      self.model_name = self.config.model
      self.ckpt_foldername = self.save_dir
      self.device = get_current_device()
      self.ckpt_prefix = ""
  
      if hasattr(self.trainer.model, "get_ckpt_name"):
          self.ckpt_prefix = self.trainer.model.get_ckpt_name() + "_"
  
      self.pth_filepath = os.path.join(
          self.ckpt_foldername,
          self.ckpt_prefix + self.model_name + "_final.pth",
      )
  
      self.models_foldername = os.path.join(
          self.ckpt_foldername, "models"
      )
      if not PathManager.exists(self.models_foldername):
          PathManager.mkdirs(self.models_foldername)
  
      self.save_config()
  
      self.repo_path = updir(os.path.abspath(__file__), n=3)
      self.git_repo = None
      if git and self.config.checkpoint.save_git_details:
          try:
              self.git_repo = git.Repo(self.repo_path)
          except git.exc.InvalidGitRepositoryError:
              # Not a git repo, don't do anything
              pass
  
      self.max_to_keep = self.config.checkpoint.max_to_keep
      self.saved_iterations = []
  
imports: import glob
  import importlib
  import logging
  import os
  import sys
  import warnings
  from typing import Any, Dict
  import torch
  from mmf.common.registry import registry
  from mmf.utils.checkpoint_updater import get_pretrained_state_mapping_checkpoint
  from mmf.utils.configuration import get_mmf_env, load_yaml
  from mmf.utils.distributed import is_main, is_xla, open_if_main, synchronize
  from mmf.utils.download import download_pretrained_model
  from mmf.utils.file_io import PathManager
  from mmf.utils.general import get_current_device, updir
  from mmf.utils.xla import save_xla_ckpt
  from omegaconf import OmegaConf
label_desc: Use image node_id 1 to create a new Checkpoint object  with example: obj = Checkpoint(trainer)