docstr: Copy the ``.grad`` attribute from stored references to fp16 parameters to
  the ``.grad`` attribute of the fp32 master parameters that are directly
  updated by the optimizer.  :attr:`update_master_grads` only needs to be called if
  ``fp16_optimizer_obj.backward`` was called with ``update_master_grads=False``.
docstr_tok: ["Copy","the","``",".grad","``","attribute","from","stored","references","to","fp16","parameters","to","the","``",".grad","``","attribute","of","the","fp32","master","parameters","that","are","directly","updated","by","the","optimizer",".",":","attr",":","`","update_master_grads","`","only","needs","to","be","called","if","``","fp16_optimizer_obj.backward","``","was","called","with","``","update_master_grads=False","``","."]
code: def update_master_grads(self):
      # torch.cuda.nvtx.range_push("update_master_grads")
      """
      Copy the ``.grad`` attribute from stored references to fp16 parameters to
      the ``.grad`` attribute of the fp32 master parameters that are directly
      updated by the optimizer.  :attr:`update_master_grads` only needs to be called if
      ``fp16_optimizer_obj.backward`` was called with ``update_master_grads=False``.
      """
      # if self.dynamic_loss_scale:
      #     self._check_overflow()
      #     if self.overflow: return
      # self._model_grads_to_master_grads()
      # self._downscale_master()
      # Use the one-shot multi-tensor apply kernel
      self.loss_scaler.clear_overflow_state()
      if len(self.all_fp16_params) > 0:
          # print("Model grads before")
          # print([param.grad.data for param in self.all_fp16_params])
          # I'm ONLY writing this as an incremental way to make some tests pass until
          # I can refactor the tests as well.
          # FP16_Optimizer should not be used by anyone.
          model_grads = []
          master_grads = []
          for model_param, master_param in zip(
              self.all_fp16_params, self.all_fp32_from_fp16_params
          ):
              if model_param.grad is not None:
                  model_grads.append(model_param.grad)
                  if master_param.grad is None:
                      master_param.grad = torch.empty_like(master_param)
                  master_grads.append(master_param.grad)
          self.loss_scaler.unscale(
              model_grads, master_grads, self.loss_scaler.loss_scale()
          )
          # print("Master grads after")
          # print([param.grad.data for param in self.all_fp32_from_fp16_params])
      if len(self.all_fp32_from_fp32_params) > 0:
          model_grads = []
          master_grads = []
          for model_param, master_param in zip(
              self.all_fp32_from_fp32_params,
              self.all_fp32_from_fp32_params,
          ):
              if model_param.grad is not None:
                  model_grads.append(model_param.grad)
                  master_grads.append(master_param.grad)
          # print("Model grads before")
          # print([param.grad.data for param in self.all_fp32_from_fp32_params])
          self.loss_scaler.unscale(
              model_grads, master_grads, self.loss_scaler.loss_scale()
          )
          # print("Master grads after")
          # print([param.grad.data for param in self.all_fp32_from_fp32_params])
      # quit()
      self.overflow = self.loss_scaler.update_scale()
  
imports: import torch
  from torch import nn
  from torch.autograd import Variable
  from torch.nn.parameter import Parameter
  from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors
  from ..amp._amp_state import _amp_state, maybe_print
  from ..amp.scaler import LossScaler
  from ..multi_tensor_apply import multi_tensor_applier
  from .fp16util import model_grads_to_master_grads, master_params_to_model_params, clip_grad_norm
label_desc: Use image node_id 13 for calling the FP16_Optimizer obj's underlying member method code with example usage: obj.update_master_grads() without return types