docstr: Multiplies ('scales') a tensor or list of tensors by the scale factor.
  
  Returns scaled outputs.  If this instance of :class:`GradScaler` is not enabled, outputs are returned
  unmodified.
  
  Arguments:
      outputs (Tensor or iterable of Tensors):  Outputs to scale.
docstr_tok: ["Multiplies","(","'scales","'",")","a","tensor","or","list","of","tensors","by","the","scale","factor",".","Returns","scaled","outputs",".","If","this","instance","of",":","class",":","`","GradScaler","`","is","not","enabled",",","outputs","are","returned","unmodified",".","Arguments",":","outputs","(","Tensor","or","iterable","of","Tensors",")",":","Outputs","to","scale","."]
code: def scale(self, outputs):
      """
      Multiplies ('scales') a tensor or list of tensors by the scale factor.
  
      Returns scaled outputs.  If this instance of :class:`GradScaler` is not enabled, outputs are returned
      unmodified.
  
      Arguments:
          outputs (Tensor or iterable of Tensors):  Outputs to scale.
      """
      if not self._enabled:
          return outputs
      self.scale_clip()
      # Short-circuit for the common case.
      if isinstance(outputs, torch.Tensor):
          assert outputs.is_cuda
          if self._scale is None:
              self._lazy_init_scale_growth_tracker(outputs.device)
          assert self._scale is not None
          return outputs * self._scale.to(
              device=outputs.device, non_blocking=True
          )
  
      # Invoke the more complex machinery only if we're treating multiple outputs.
      stash: List[
          _MultiDeviceReplicator
      ] = []  # holds a reference that can be overwritten by apply_scale
  
      def apply_scale(val):
          if isinstance(val, torch.Tensor):
              assert val.is_cuda
              if len(stash) == 0:
                  if self._scale is None:
                      self._lazy_init_scale_growth_tracker(val.device)
                  assert self._scale is not None
                  stash.append(_MultiDeviceReplicator(self._scale))
              return val * stash[0].get(val.device)
          elif isinstance(val, container_abcs.Iterable):
              iterable = map(apply_scale, val)
              if isinstance(val, list) or isinstance(val, tuple):
                  return type(val)(iterable)
              else:
                  return iterable
          else:
              raise ValueError(
                  "outputs must be a Tensor or an iterable of Tensors"
              )
  
      return apply_scale(outputs)
  
file_path: insightface/reconstruction/jmlr/utils/utils_amp.py
imports: from typing import Dict, List
  import torch
  import collections.abc
  from torch.cuda.amp import GradScaler
label_desc: Use image node_id 3 for calling the MaxClipGradScaler obj's underlying member method code with example usage: obj.scale(outputs) and returns: apply_scale, outputs, unknown, unknown, type, iterable