code: def __init__(
      self,
      params,
      lr=1e-2,
      lr_decay=0,
      weight_decay=0,
      initial_accumulator_value=0,
      eps=1e-10,
      foreach: Optional[bool] = None,
      *,
      maximize: bool = False,
      differentiable: bool = False,
  ):
      if not 0.0 <= lr:
          raise ValueError(f"Invalid learning rate: {lr}")
      if not 0.0 <= lr_decay:
          raise ValueError(f"Invalid lr_decay value: {lr_decay}")
      if not 0.0 <= weight_decay:
          raise ValueError(
              f"Invalid weight_decay value: {weight_decay}"
          )
      if not 0.0 <= initial_accumulator_value:
          raise ValueError(
              f"Invalid initial_accumulator_value value: {initial_accumulator_value}"
          )
      if not 0.0 <= eps:
          raise ValueError(f"Invalid epsilon value: {eps}")
  
      defaults = dict(
          lr=lr,
          lr_decay=lr_decay,
          eps=eps,
          weight_decay=weight_decay,
          initial_accumulator_value=initial_accumulator_value,
          foreach=foreach,
          maximize=maximize,
          differentiable=differentiable,
      )
      super().__init__(params, defaults)
  
      for group in self.param_groups:
          for p in group["params"]:
              state = self.state[p]
              state["step"] = torch.tensor(
                  0.0, dtype=_get_scalar_dtype()
              )
              init_value = (
                  complex(
                      initial_accumulator_value,
                      initial_accumulator_value,
                  )
                  if torch.is_complex(p)
                  else initial_accumulator_value
              )
              state["sum"] = torch.full_like(
                  p, init_value, memory_format=torch.preserve_format
              )
  
file_path: pytorch/torch/optim/adagrad.py
imports: import torch
  from torch import Tensor
  from .optimizer import Optimizer, _use_grad_for_differentiable, _get_value, _view_as_real, _default_to_fused_or_foreach, _get_scalar_dtype, _differentiable_doc, _foreach_doc, _maximize_doc
  from typing import List, Optional
label_desc: Use image node_id 1 to create a new Adagrad object from inherited base classes: Optimizer with example: obj = Adagrad(params, lr, lr_decay, weight_decay, initial_accumulator_value, eps, foreach)