class_docstr: An instance ``scaler`` helps perform the steps of gradient scaling
  conveniently.
class_docstr_tok: ["An","instance","``","scaler","``","helps","perform","the","steps","of","gradient","scaling","conveniently","."]
code: def __init__(
      self,
      init_scale: float = 2.0**15,
      scale_factor: float = 2.0,
      scale_window: int = 2000,
      tolerance: float = 0.0,
      threshold: float = None,
      min_loss_scale: float = 1e-4,
  ):
      self.loss_scale = init_scale
      self.scale_factor = scale_factor
      self.scale_window = scale_window
      self.tolerance = tolerance
      self.threshold = threshold
      self.min_loss_scale = min_loss_scale
      self._iter = 0
      self._last_overflow_iter = -1
      self._last_rescale_iter = -1
      self._overflows_since_rescale = 0
      self._per_optimizer_states: Dict[int, OptState] = defaultdict(
          _refresh_per_optimizer_state
      )
      self._scale = None
  
file_path: fairscale/fairscale/experimental/optim/dynamic_loss_scaler.py
imports: from collections import defaultdict
  from enum import Enum
  from typing import Dict, List, Optional
  import torch
label_desc: Use image node_id 1 to create a new DynamicLossScaler object from inherited base classes: object with example: obj = DynamicLossScaler(init_scale, scale_factor, scale_window, tolerance, threshold, min_loss_scale)