code: def __init__(
      self,
      params: Params,
      lr: float = 1e-3,
      momentum: float = 0.0,
      nu: float = 0.7,
      weight_decay: float = 0.0,
      weight_decay_type: str = "grad",
  ) -> None:
      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 weight_decay_type not in (self.GRAD, self.DIRECT):
          _type = weight_decay_type
          msg = "Invalid weight_decay_type value: {}".format(_type)
          raise ValueError(msg)
  
      defaults = {
          "lr": lr,
          "momentum": momentum,
          "nu": nu,
          "weight_decay": weight_decay,
          "weight_decay_type": weight_decay_type,
      }
      super(QHM, 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 QHM object from inherited base classes: Optimizer with example: obj = QHM(params, lr, momentum, nu, weight_decay, weight_decay_type)