class_docstr: Implements Shampoo Optimizer Algorithm.
  
  It has been proposed in `Shampoo: Preconditioned Stochastic Tensor
  Optimization`__.
  
  Arguments:
      params: iterable of parameters to optimize or dicts defining
          parameter groups
      lr: learning rate (default: 1e-3)
      momentum: momentum factor (default: 0)
      weight_decay: weight decay (L2 penalty) (default: 0)
      epsilon: epsilon added to each mat_gbar_j for numerical stability
          (default: 1e-4)
      update_freq: update frequency to compute inverse (default: 1)
  
  Example:
      >>> import torch_optimizer as optim
      >>> optimizer = optim.Shampoo(model.parameters(), lr=0.01)
      >>> optimizer.zero_grad()
      >>> loss_fn(model(input), target).backward()
      >>> optimizer.step()
  
  __ https://arxiv.org/abs/1802.09568
  
  Note:
      Reference code: https://github.com/moskomule/shampoo.pytorch
code: def __init__(
      self,
      params: Params,
      lr: float = 1e-1,
      momentum: float = 0.0,
      weight_decay: float = 0.0,
      epsilon: float = 1e-4,
      update_freq: int = 1,
  ):
      if lr <= 0.0:
          raise ValueError("Invalid learning rate: {}".format(lr))
      if momentum < 0.0:
          raise ValueError(
              "Invalid momentum value: {}".format(momentum)
          )
      if weight_decay < 0.0:
          raise ValueError(
              "Invalid weight_decay value: {}".format(weight_decay)
          )
      if epsilon < 0.0:
          raise ValueError(
              "Invalid momentum value: {}".format(momentum)
          )
      if update_freq < 1:
          raise ValueError(
              "Invalid momentum value: {}".format(momentum)
          )
  
      defaults = dict(
          lr=lr,
          momentum=momentum,
          weight_decay=weight_decay,
          epsilon=epsilon,
          update_freq=update_freq,
      )
      super(Shampoo, self).__init__(params, defaults)
  
imports: import torch
  from torch.optim.optimizer import Optimizer
  from .types import OptFloat, OptLossClosure, Params
label_desc: Use image node_id 1 to create a new Shampoo object from inherited base classes: Optimizer with example: obj = Shampoo(params, lr, momentum, weight_decay, epsilon, update_freq)