code: def post_backward_models_are_masters(
      scaler, params, stashed_grads, scale_override=None
  ):
      grads_have_scale, stashed_have_scale, out_scale = (
          scaler.loss_scale(),
          1.0,
          1.0,
      )
  
      # not much to do if scale == 1.0 and static scaling
      if scaler.loss_scale() == 1.0 and not scaler.dynamic:
          # Clear the stash.
          for i in range(len(stashed_grads)):
              stashed_grads[i] = None
          return
  
      if scale_override is not None:
          (
              grads_have_scale,
              stashed_have_scale,
              out_scale,
          ) = scale_override
  
      # This is a lot of python overhead...
      grads_needing_unscale = []
      grads_needing_unscale_with_stash = []
      stashed = []
      for param, stashed_grad in zip(params, stashed_grads):
          if param.grad is None and stashed_grad is not None:
              param.grad = stashed_grad
          elif param.grad is not None and stashed_grad is None:
              grads_needing_unscale.append(param.grad)
          elif param.grad is not None and stashed_grad is not None:
              grads_needing_unscale_with_stash.append(param.grad)
              stashed.append(stashed_grad)
          else:  # param.grad is None and stashed_grad is None
              continue
  
      # unscale() implements grads*(1/scale), so "scale" should be grads_have_scale/out_scale.
      if len(grads_needing_unscale) > 0:
          scaler.unscale(
              grads_needing_unscale,
              grads_needing_unscale,
              None,  # unused_scale, currently present to avoid API breakage elsewhere
              models_are_masters=True,
              scale_override=grads_have_scale / out_scale,
          )
  
      if len(grads_needing_unscale_with_stash) > 0:
          scaler.unscale_with_stashed(
              grads_needing_unscale_with_stash,
              stashed,
              grads_needing_unscale_with_stash,
              scale_override=(
                  grads_have_scale,
                  stashed_have_scale,
                  out_scale,
              ),
          )
  
      # Clear the stash.
      for i in range(len(stashed_grads)):
          stashed_grads[i] = None
  
imports: import types
  from ..fp16_utils import master_params_to_model_params
  from ..multi_tensor_apply import multi_tensor_applier
  from ._amp_state import maybe_print
  import torch
  from ..optimizers import FusedSGD
label_desc: Use image node_id 3 for calling a global function with example usage: post_backward_models_are_masters(scaler, params, stashed_grads, scale_override) without return types