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: Requires a scheduler that is based on iterations instead of epochs.
docstr_tok: ["Requires","a","scheduler","that","is","based","on","iterations","instead","of","epochs","."]
code: def optimizer_step(self):
      """Requires a scheduler that is based on iterations instead of epochs."""
      self.steps += 1
      if self.accumulated_samples >= self.current_batch_size:
          self.accumulated_samples = 0
  
          if self.cfg_train.gradient_clipping is not None:
              self.scaler.unscale_(self.optimizer)
              torch.nn.utils.clip_grad_norm_(
                  self.model.parameters(),
                  self.cfg_train.gradient_clipping,
                  norm_type=2.0,
              )
          self.scaler.step(self.optimizer)
          self.scaler.update()
          self.optimizer.zero_grad()
          self.schedule_batch_size()
      self.scheduler.step()
  
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 7 for calling the TorchEngineMinimal obj's underlying member method code with example usage: obj.optimizer_step() without return types