class_docstr: Mixed precision training using Pytorch's Automatic Mixed Precision (AMP)
class_docstr_tok: ["Mixed","precision","training","using","Pytorch","'s","Automatic","Mixed","Precision","(","AMP",")"]
docstr: Use `self` as a fake optimizer. `self.skipped` will be set to True `after_step` if gradients overflow.
docstr_tok: ["Use","`","self","`","as","a","fake","optimizer",".","`","self.skipped","`","will","be","set","to","True","`","after_step","`","if","gradients","overflow","."]
code: def before_step(self):
      "Use `self` as a fake optimizer. `self.skipped` will be set to True `after_step` if gradients overflow."
      self.skipped = True
      self.scaler.step(self)
      if self.skipped:
          raise CancelStepException()
      self.scales.append(self.scaler.get_scale())
  
imports: from __future__ import annotations
  from ..basics import *
  from .progress import *
  from torch.cuda.amp import GradScaler, autocast
  from torch.cuda.amp.grad_scaler import OptState
  from ..fp16_utils import convert_network, model_grads_to_master_grads, master_params_to_model_params
  from torch.nn.utils import parameters_to_vector
label_desc: Use image node_id 7 for calling the MixedPrecision obj's underlying member method code with example usage: obj.before_step() without return types