class_docstr: This class mirrors deepspeed functionality. Not all changes are implemented in this version.
  
  See TorchEngineFull for more modifications.
class_docstr_tok: ["This","class","mirrors","deepspeed","functionality",".","Not","all","changes","are","implemented","in","this","version",".","See","TorchEngineFull","for","more","modifications","."]
docstr: Load list of states from checkpoint file. Not generally compatible with any other engine?
docstr_tok: ["Load","list","of","states","from","checkpoint","file",".","Not","generally","compatible","with","any","other","engine","?"]
code: def load_checkpoint(self, cfg_arch, file, skip_optim_state=True):
      """Load list of states from checkpoint file. Not generally compatible with any other engine?"""
      if file.startswith("hf://"):
          if file.endswith("-untrained"):
              log.info(
                  "Loading NO pretrained model as a sanity check ..."
              )
          else:
              self.model = self.model.from_pretrained(
                  file.split("hf://")[1], config=cfg_arch
              ).to(**self.setup)
              # reinit optimizer:
              self.optimizer, self.scheduler = _load_optimizer(
                  self.model, self.cfg_train, self.cfg_impl
              )
      else:
          model_state = load_file(
              file, device=str(self.setup["device"])
          )
          # This loader includes a few legacy options:
          if (
              "encoder.embedding.word_embedding.weight"
              not in model_state
          ):
              # Hack to save space when saving the model, more clever though would be save the right one in the first place
              model_state[
                  "encoder.embedding.word_embedding.weight"
              ] = model_state["decoder.weight"]
          try:
              sanitized_state = {}
              for k, v in model_state.items():
                  if k.startswith("module."):
                      k = k[7:]
                  if self.cfg_impl.compile_torch:
                      k = f"_orig_mod.{k}"
                  if torch.distributed.is_initialized():
                      k = f"module.{k}"
                  sanitized_state[k] = v
              self.model.load_state_dict(sanitized_state, strict=True)
          except RuntimeError as e:
              log.info(
                  f"State dict difference is {str(e).split('Error(s) in loading state_dict for')[1]}... Ok?"
              )
              self.model.load_state_dict(sanitized_state, strict=False)
          self.model.to(**self.setup)
  
imports: import torch
  import torch._inductor.utils
  import os
  import json
  from omegaconf import OmegaConf
  from functools import partial
  from contextlib import nullcontext
  import time
  import logging
  import transformers
  from safetensors.torch import load_file, save_file
  from transformers.utils.generic import working_or_temp_dir
  from torch.distributed.optim import ZeroRedundancyOptimizer
  from .utils import group_parameters, prepare_pretraining_dataloader, update_ema, updated_latest_weight_average
  from .optimizers.schedulers import get_schedule_fn
  from .optimizers import Adahessian, AdamWScale, Shampoo, LARS, SAM, ProgressiveBatching, AGD, Sophia
  import warnings
label_desc: Use image node_id 14 for calling the TorchEngineMinimal obj's underlying member method code with example usage: obj.load_checkpoint(cfg_arch, file, skip_optim_state) without return types