class_docstr: Class that manages loss scaling in mixed precision training which
  supports both dynamic or static mode.
  
  The implementation refers to
  https://github.com/NVIDIA/apex/blob/master/apex/fp16_utils/loss_scaler.py.
  Indirectly, by supplying ``mode='dynamic'`` for dynamic loss scaling.
  It's important to understand how :class:`LossScaler` operates.
  Loss scaling is designed to combat the problem of underflowing
  gradients encountered at long times when training fp16 networks.
  Dynamic loss scaling begins by attempting a very high loss
  scale.  Ironically, this may result in OVERflowing gradients.
  If overflowing gradients are encountered, :class:`FP16_Optimizer` then
  skips the update step for this particular iteration/minibatch,
  and :class:`LossScaler` adjusts the loss scale to a lower value.
  If a certain number of iterations occur without overflowing gradients
  detected,:class:`LossScaler` increases the loss scale once more.
  In this way :class:`LossScaler` attempts to "ride the edge" of always
  using the highest loss scale possible without incurring overflow.
  
  Args:
      init_scale (float): Initial loss scale value, default: 2**32.
      scale_factor (float): Factor used when adjusting the loss scale.
          Default: 2.
      mode (str): Loss scaling mode. 'dynamic' or 'static'
      scale_window (int): Number of consecutive iterations without an
          overflow to wait before increasing the loss scale. Default: 1000.
class_docstr_tok: ["Class","that","manages","loss","scaling","in","mixed","precision","training","which","supports","both","dynamic","or","static","mode",".","The","implementation","refers","to","https",":","\/\/github.com\/NVIDIA\/apex\/blob\/master\/apex\/fp16_utils\/loss_scaler.py",".","Indirectly",",","by","supplying","``","mode='dynamic","'","``","for","dynamic","loss","scaling",".","It","'s","important","to","understand","how",":","class",":","`","LossScaler","`","operates",".","Loss","scaling","is","designed","to","combat","the","problem","of","underflowing","gradients","encountered","at","long","times","when","training","fp16","networks",".","Dynamic","loss","scaling","begins","by","attempting","a","very","high","loss","scale",".","Ironically",",","this","may","result","in","OVERflowing","gradients",".","If","overflowing","gradients","are","encountered",",",":","class",":","`","FP16_Optimizer","`","then","skips","the","update","step","for","this","particular","iteration\/minibatch",",","and",":","class",":","`","LossScaler","`","adjusts","the","loss","scale","to","a","lower","value",".","If","a","certain","number","of","iterations","occur","without","overflowing","gradients","detected",",",":class",":","`","LossScaler","`","increases","the","loss","scale","once","more",".","In","this","way",":","class",":","`","LossScaler","`","attempts","to","``","ride","the","edge","''","of","always","using","the","highest","loss","scale","possible","without","incurring","overflow",".","Args",":","init_scale","(","float",")",":","Initial","loss","scale","value",",","default",":","2","*","*","32.","scale_factor","(","float",")",":","Factor","used","when","adjusting","the","loss","scale",".","Default",":","2.","mode","(","str",")",":","Loss","scaling","mode",".","'dynamic","'","or","'static'","scale_window","(","int",")",":","Number","of","consecutive","iterations","without","an","overflow","to","wait","before","increasing","the","loss","scale",".","Default",":","1000","."]
code: def loss_scale(self):
      return self.cur_scale
  
imports: import functools
  import warnings
  from collections import abc
  from inspect import getfullargspec
  import numpy
  import torch
  import torch.nn
  from annotator.uniformer.mmcv.utils import TORCH_VERSION, digit_version
  from .dist_utils import allreduce_grads
label_desc: Use image node_id 7 for calling the LossScaler obj's underlying member method code with example usage: obj.loss_scale() and returns: self