class_docstr: Gradient scaler for the PyTorch shim.
  
  Gradients with small magnitudes are not representable in half-precision and
  will underflow to zero. A gradient scaler counters this issue by scaling
  up the loss before backpropagation, increasing the gradients by the same
  magnitude. A large enough scale will avoid that the gradients underflow.
  The gradients are unscaled in single precision after backpropagation, to
  provide the unscaled gradients to the optimizer.
docstr: Unscale the given tensors. Returns True if any of the gradients were infinite.
code: def unscale(self, tensors):
      """Unscale the given tensors. Returns True if any of the gradients were infinite."""
      if not self._enabled:
          return False
  
      # Invert scale (in higher precision).
      inv_scale = self._scale.double().reciprocal().float()
  
      # Apply unscaling to tensors, per device.
      tensors_per_device = self._tensors_per_device(tensors)
      for device, device_tensors in tensors_per_device.items():
          found_inf_device = torch.full((1,), 0.0, device=device)
          inv_scale_device = inv_scale.to(device=device)
  
          torch._amp_foreach_non_finite_check_and_unscale_(
              device_tensors, found_inf_device, inv_scale_device
          )
  
          if bool(found_inf_device != 0):
              self._found_inf = True
  
      return self._found_inf
  
file_path: thinc/thinc/shims/pytorch_grad_scaler.py
imports: from typing import Dict, Iterable, List, Union, cast
  from ..compat import has_torch_amp, torch
  from ..util import is_torch_array
label_desc: Use image node_id 7 for calling the PyTorchGradScaler obj's underlying member method code with example usage: obj.unscale(tensors) and returns: self, False