class_docstr: Run training in mixed precision
class_docstr_tok: ["Run","training","in","mixed","precision"]
code: def __init__(
      self,
      loss_scale: int = 512,  # Non-dynamic loss scale, used to avoid underflow of gradients.
      flat_master: bool = False,  # Whether to flatten fp32 parameters for performance
      dynamic: bool = True,  # Whether to automatically determine loss scaling
      max_loss_scale: float = 2.0
      ** 24,  # Starting value for dynamic loss scaling
      div_factor: float = 2.0,  # Divide by this on overflow, multiply by this after scale_wait batches
      scale_wait: int = 500,  # Number of batches to wait for increasing loss scale
      clip: float = None,  # Value to clip gradients at, max_norm, as in `nn.utils.clip_grad_norm_`
  ):
      assert (
          torch.backends.cudnn.enabled
      ), "Mixed precision training requires cudnn."
      self.flat_master, self.dynamic, self.max_loss_scale = (
          flat_master,
          dynamic,
          max_loss_scale,
      )
      self.div_factor, self.scale_wait, self.clip = (
          div_factor,
          scale_wait,
          clip,
      )
      self.loss_scale = max_loss_scale if dynamic else loss_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 1 to create a new NonNativeMixedPrecision object from inherited base classes: Callback with example: obj = NonNativeMixedPrecision(loss_scale, flat_master, dynamic, max_loss_scale, div_factor, scale_wait, clip)