class_docstr: Base class for all TF1 loss scales.
  
  This is an abstract base class, so you cannot instantiate it directly.
  Instead, use one of its concrete subclasses:
    * `tf.compat.v1.mixed_precision.DynamicLossScale`
    * `tf.compat.v1.mixed_precision.FixedLossScale`
  
  Loss scaling is a process that multiplies the loss by a multiplier called the
  loss scale, and divides each gradient by the same multiplier. The pseudocode
  for this process is:
  
  ```
  loss = ...
  loss *= loss_scale
  grads = gradients(loss, vars)
  grads /= loss_scale
  ```
  
  Mathematically, loss scaling has no effect, but can help avoid numerical
  underflow in intermediate gradients when float16 tensors are used for mixed
  precision training. By multiplying the loss, each intermediate gradient will
  have the same multiplier applied.
  
  Instances of this class represent a loss scale. Calling instances of this
  class returns the loss scale as a scalar float32 tensor, while method
  `update()` updates the loss scale depending on the values of the gradients.
  Optimizers use instances of this class to scale loss and gradients.
  
  In most functions that accept a LossScale, you can also pass an int (such as
  8) to create a `FixedLossScale` or the string `"dynamic"` to create a dynamic
  loss scale.
class_docstr_tok: ["Base","class","for","all","TF1","loss","scales",".","This","is","an","abstract","base","class",",","so","you","can","not","instantiate","it","directly",".","Instead",",","use","one","of","its","concrete","subclasses",":","*","`","tf.compat.v1.mixed_precision.DynamicLossScale","`","*","`","tf.compat.v1.mixed_precision.FixedLossScale","`","Loss","scaling","is","a","process","that","multiplies","the","loss","by","a","multiplier","called","the","loss","scale",",","and","divides","each","gradient","by","the","same","multiplier",".","The","pseudocode","for","this","process","is",":","``","`","loss","=","...","loss","*","=","loss_scale","grads","=","gradients","(","loss",",","vars",")","grads","\/=","loss_scale","``","`","Mathematically",",","loss","scaling","has","no","effect",",","but","can","help","avoid","numerical","underflow","in","intermediate","gradients","when","float16","tensors","are","used","for","mixed","precision","training",".","By","multiplying","the","loss",",","each","intermediate","gradient","will","have","the","same","multiplier","applied",".","Instances","of","this","class","represent","a","loss","scale",".","Calling","instances","of","this","class","returns","the","loss","scale","as","a","scalar","float32","tensor",",","while","method","`","update","(",")","`","updates","the","loss","scale","depending","on","the","values","of","the","gradients",".","Optimizers","use","instances","of","this","class","to","scale","loss","and","gradients",".","In","most","functions","that","accept","a","LossScale",",","you","can","also","pass","an","int","(","such","as","8",")","to","create","a","`","FixedLossScale","`","or","the","string","`","``","dynamic","''","`","to","create","a","dynamic","loss","scale","."]
docstr: Initializes the loss scale class.
docstr_tok: ["Initializes","the","loss","scale","class","."]
code: def __init__(self):
      """Initializes the loss scale class."""
      self._weights = {}
  
imports: import abc
  from tensorflow.python.distribute import distribute_lib
  from tensorflow.python.distribute import reduce_util
  from tensorflow.python.eager import context
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import cond
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import variable_v1
  from tensorflow.python.ops import variables
  from tensorflow.python.trackable import base
  from tensorflow.python.util import deprecation
  from tensorflow.python.util import nest
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 1 to create a new LossScale object from inherited base classes: trackable with example: obj = LossScale()