code: def _fused_sgd(
      params: List[Tensor],
      grads: List[Tensor],
      momentum_buffer_list: List[Optional[Tensor]],
      grad_scale: Optional[Tensor],
      found_inf: Optional[Tensor],
      *,
      weight_decay: float,
      momentum: float,
      lr: float,
      dampening: float,
      nesterov: bool,
      maximize: bool,
      has_sparse_grad: bool,
  ) -> None:
      if not params:
          return
      if has_sparse_grad:
          raise RuntimeError(
              "`_fused_sgd` does not support sparse gradients"
          )
      grad_scale_dict = (
          {grad_scale.device: grad_scale}
          if grad_scale is not None
          else None
      )
      found_inf_dict = (
          {found_inf.device: found_inf}
          if found_inf is not None
          else None
      )
  
      no_momentum_buffer = momentum == 0
      is_first_step = (
          all(t is None for t in momentum_buffer_list)
          and not no_momentum_buffer
      )
      if is_first_step:
          for i, g in enumerate(grads):
              momentum_buffer_list[i] = torch.empty_like(g)
      grouped_tensors = Optimizer._group_tensors_by_device_and_dtype(
          [params, grads, momentum_buffer_list], with_indices=False
      )
      for (device, dtype), (
          (device_params, device_grads, device_momentum_buffer_list),
          _,
      ) in grouped_tensors.items():
          device_grad_scale, device_found_inf = None, None
          if grad_scale is not None:
              if device not in grad_scale_dict:
                  grad_scale_dict[device] = grad_scale.to(device)
              device_grad_scale = grad_scale_dict[device]
          if found_inf is not None:
              if device not in found_inf_dict:
                  found_inf_dict[device] = found_inf.to(device)
              device_found_inf = found_inf_dict[device]
          torch._fused_sgd_(
              device_params,
              device_grads,
              [] if no_momentum_buffer else device_momentum_buffer_list,
              weight_decay=weight_decay,
              momentum=momentum,
              lr=lr,
              dampening=dampening,
              nesterov=nesterov,
              maximize=maximize,
              is_first_step=is_first_step,
              grad_scale=device_grad_scale,
              found_inf=device_found_inf,
          )
  
file_path: pytorch/torch/optim/sgd.py
imports: import torch
  from torch import Tensor
  from .optimizer import Optimizer, _use_grad_for_differentiable, _default_to_fused_or_foreach, _differentiable_doc, _foreach_doc, _maximize_doc, _fused_doc
  from typing import List, Optional
label_desc: Use image node_id 4 for calling a global function with example usage: _fused_sgd(params, grads, momentum_buffer_list, grad_scale, found_inf) without return types