class_docstr: An optimizer that dynamically scales the loss to prevent underflow.
  
  Loss scaling is a technique to prevent numeric underflow in intermediate
  gradients when float16 is used. To prevent underflow, the loss is multiplied
  (or "scaled") by a certain factor called the "loss scale", which causes
  intermediate gradients to be scaled by the loss scale as well. The final
  gradients are divided (or "unscaled") by the loss scale to bring them back
  to their original value.
  
  `LossScaleOptimizer` wraps another optimizer and applies dynamic loss
  scaling to it. This loss scale is dynamically updated over time as follows:
  - On any train step, if a nonfinite gradient is encountered, the loss scale
    is halved, and the train step is skipped.
  - If `dynamic_growth_steps` have ocurred since the last time the loss scale
    was updated, and no nonfinite gradients have occurred, the loss scale
    is doubled.
  
  Args:
      inner_optimizer: The `keras.optimizers.Optimizer` instance to wrap.
      initial_scale: Float. The initial loss scale. This scale will be updated
          during training. It is recommended for this to be a very high
          number, because a loss scale that is too high gets lowered far more
          quickly than a loss scale that is too low gets raised.
      dynamic_growth_steps: Int. How often to update the scale upwards. After
          every `dynamic_growth_steps` steps with finite gradients, the
          loss scale is doubled.
      {{base_optimizer_keyword_args}}
class_docstr_tok: ["An","optimizer","that","dynamically","scales","the","loss","to","prevent","underflow",".","Loss","scaling","is","a","technique","to","prevent","numeric","underflow","in","intermediate","gradients","when","float16","is","used",".","To","prevent","underflow",",","the","loss","is","multiplied","(","or","``","scaled","''",")","by","a","certain","factor","called","the","``","loss","scale","''",",","which","causes","intermediate","gradients","to","be","scaled","by","the","loss","scale","as","well",".","The","final","gradients","are","divided","(","or","``","unscaled","''",")","by","the","loss","scale","to","bring","them","back","to","their","original","value",".","`","LossScaleOptimizer","`","wraps","another","optimizer","and","applies","dynamic","loss","scaling","to","it",".","This","loss","scale","is","dynamically","updated","over","time","as","follows",":","-","On","any","train","step",",","if","a","nonfinite","gradient","is","encountered",",","the","loss","scale","is","halved",",","and","the","train","step","is","skipped",".","-","If","`","dynamic_growth_steps","`","have","ocurred","since","the","last","time","the","loss","scale","was","updated",",","and","no","nonfinite","gradients","have","occurred",",","the","loss","scale","is","doubled",".","Args",":","inner_optimizer",":","The","`","keras.optimizers.Optimizer","`","instance","to","wrap",".","initial_scale",":","Float",".","The","initial","loss","scale",".","This","scale","will","be","updated","during","training",".","It","is","recommended","for","this","to","be","a","very","high","number",",","because","a","loss","scale","that","is","too","high","gets","lowered","far","more","quickly","than","a","loss","scale","that","is","too","low","gets","raised",".","dynamic_growth_steps",":","Int",".","How","often","to","update","the","scale","upwards",".","After","every","`","dynamic_growth_steps","`","steps","with","finite","gradients",",","the","loss","scale","is","doubled",".","{","{","base_optimizer_keyword_args","}","}"]
code: def _common_apply(self, grads, trainable_variables=None):
      finite = self.check_finite(grads)
      ops.cond(
          finite,
          lambda: self._stateful_handle_finite_grads(
              grads, trainable_variables
          ),
          self._stateful_handle_non_finite_grads,
      )
  
imports: from keras import backend
  from keras import initializers
  from keras import ops
  from keras.api_export import keras_export
  from keras.optimizers import optimizer
  from keras.saving import serialization_lib
  from keras.utils import tracking
label_desc: Use image node_id 10 for calling the LossScaleOptimizer obj's underlying member method code with example usage: obj._common_apply(grads, trainable_variables) without return types