class_docstr: An instance ``scaler`` helps perform the steps of gradient scaling
  conveniently.
class_docstr_tok: ["An","instance","``","scaler","``","helps","perform","the","steps","of","gradient","scaling","conveniently","."]
code: def unscale_(self, optimizer: torch.optim.Optimizer) -> None:
      # uncale the gradients.
      optimizer_state = self._per_optimizer_states[id(optimizer)]
  
      if optimizer_state is OptState.UNSCALED:
          raise RuntimeError(
              "unscale_() has already been called on this optimizer since the last update()."
          )
      elif optimizer_state is OptState.STEPPED:
          raise RuntimeError("unscale_() is being called after step().")
  
      assert self.loss_scale is not None
      inv_scale = 1.0 / float(self.loss_scale)
  
      with torch.no_grad():
          for group in optimizer.param_groups:
              for param in group["params"]:
                  if param.grad is None:
                      continue
                  else:
                      param.grad.data.mul_(inv_scale)
  
      optimizer_state = OptState.UNSCALED
  
file_path: fairscale/fairscale/experimental/optim/dynamic_loss_scaler.py
imports: from collections import defaultdict
  from enum import Enum
  from typing import Dict, List, Optional
  import torch
label_desc: Use image node_id 8 for calling the DynamicLossScaler obj's underlying member method code with example usage: obj.unscale_(optimizer) without return types