code: def post_backward_with_master_weights(self, scaler):
      stash = self._amp_stash
  
      self._amp_lazy_init()
  
      # This is a lot of python overhead...
      fp16_grads_needing_unscale = []
      new_fp32_grads = []
      fp16_grads_needing_unscale_with_stash = []
      preexisting_fp32_grads = []
      for fp16_param, fp32_param in zip(
          stash.all_fp16_params, stash.all_fp32_from_fp16_params
      ):
          if fp16_param.grad is None and fp32_param.grad is not None:
              continue
          elif fp16_param.grad is not None and fp32_param.grad is None:
              fp32_param.grad = torch.empty_like(fp32_param)
              fp16_grads_needing_unscale.append(fp16_param.grad)
              new_fp32_grads.append(fp32_param.grad)
          elif (
              fp16_param.grad is not None
              and fp32_param.grad is not None
          ):
              fp16_grads_needing_unscale_with_stash.append(
                  fp16_param.grad
              )
              preexisting_fp32_grads.append(fp32_param.grad)
          else:  # fp16_param.grad is None and fp32_param.grad is None:
              continue
  
      if len(fp16_grads_needing_unscale) > 0:
          scaler.unscale(
              fp16_grads_needing_unscale,
              new_fp32_grads,
              scaler.loss_scale(),
              models_are_masters=False,
          )
  
      if len(fp16_grads_needing_unscale_with_stash) > 0:
          scaler.unscale_with_stashed(
              fp16_grads_needing_unscale_with_stash,
              preexisting_fp32_grads,
              preexisting_fp32_grads,
          )
  
      # fp32 params can be treated as they would be in the "no_master_weights" case.
      post_backward_models_are_masters(
          scaler,
          stash.all_fp32_from_fp32_params,
          stash.all_fp32_from_fp32_grad_stash,
      )
  
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 5 for calling a global function with example usage: post_backward_with_master_weights(scaler) without return types