class_docstr: EXPERIMENTAL Discrete Cosine Transform-augmented
  :class:`~pyro.optim.clipped_adam.ClippedAdam` optimizer.
  
  This acts like :class:`~pyro.optim.clipped_adam.ClippedAdam` on most
  parameters, but if a parameter has an attribute ``._pyro_dct_dim``
  indicating a time dimension, this creates a secondary optimize in the
  frequency domain. This is useful for parameters of time series models.
  
  :param params: iterable of parameters to optimize or dicts defining parameter groups
  :param float lr: learning rate (default: 1e-3)
  :param tuple betas: coefficients used for computing
      running averages of gradient and its square (default: (0.9, 0.999))
  :param float eps: term added to the denominator to improve
      numerical stability (default: 1e-8)
  :param float clip_norm: magnitude of norm to which gradients are clipped (default: 10.0)
  :param float lrd: rate at which learning rate decays (default: 1.0)
  :param bool subsample_aware: whether to update gradient statistics only for
      those elements that appear in a subsample (default: False).
class_docstr_tok: ["EXPERIMENTAL","Discrete","Cosine","Transform-augmented",":","class",":","`","~pyro.optim.clipped_adam.ClippedAdam","`","optimizer",".","This","acts","like",":","class",":","`","~pyro.optim.clipped_adam.ClippedAdam","`","on","most","parameters",",","but","if","a","parameter","has","an","attribute","``","._pyro_dct_dim","``","indicating","a","time","dimension",",","this","creates","a","secondary","optimize","in","the","frequency","domain",".","This","is","useful","for","parameters","of","time","series","models",".",":","param","params",":","iterable","of","parameters","to","optimize","or","dicts","defining","parameter","groups",":","param","float","lr",":","learning","rate","(","default",":","1e-3",")",":","param","tuple","betas",":","coefficients","used","for","computing","running","averages","of","gradient","and","its","square","(","default",":","(","0.9",",","0.999",")",")",":","param","float","eps",":","term","added","to","the","denominator","to","improve","numerical","stability","(","default",":","1e-8",")",":","param","float","clip_norm",":","magnitude","of","norm","to","which","gradients","are","clipped","(","default",":","10.0",")",":","param","float","lrd",":","rate","at","which","learning","rate","decays","(","default",":","1.0",")",":","param","bool","subsample_aware",":","whether","to","update","gradient","statistics","only","for","those","elements","that","appear","in","a","subsample","(","default",":","False",")","."]
code: def _step_param(self, group: Dict, p) -> None:
      grad = p.grad.data
      grad.clamp_(-group["clip_norm"], group["clip_norm"])
  
      # Transform selected parameters via dct.
      time_dim = getattr(p, "_pyro_dct_dim", None)
      if time_dim is not None:
          duration = p.size(time_dim)
          grad = _transform_forward(grad, time_dim, duration)
  
      state = self.state[p]
  
      # State initialization
      if len(state) == 0:
          state["step"] = 0
          # Exponential moving average of gradient values
          state["exp_avg"] = torch.zeros_like(grad)
          # Exponential moving average of squared gradient values
          state["exp_avg_sq"] = torch.zeros_like(grad)
  
      exp_avg, exp_avg_sq = state["exp_avg"], state["exp_avg_sq"]
      beta1, beta2 = group["betas"]
  
      state["step"] += 1
  
      # Decay the first and second moment running average coefficient
      exp_avg.mul_(beta1).add_(grad, alpha=1 - beta1)
      exp_avg_sq.mul_(beta2).addcmul_(grad, grad, value=1 - beta2)
  
      denom = exp_avg_sq.sqrt().add_(group["eps"])
  
      bias_correction1 = 1 - beta1 ** state["step"]
      bias_correction2 = 1 - beta2 ** state["step"]
      step_size = (
          group["lr"] * math.sqrt(bias_correction2) / bias_correction1
      )
  
      if time_dim is None:
          p.data.addcdiv_(exp_avg, denom, value=-step_size)
      else:
          step = _transform_inverse(exp_avg / denom, time_dim, duration)
          p.data.add_(step.mul_(-step_size))
  
file_path: pyro/pyro/optim/dct_adam.py
imports: import math
  from typing import Callable, Dict, Optional, Tuple
  import torch
  from torch.nn.functional import pad
  from torch.optim.optimizer import Optimizer
  from pyro.ops.tensor_utils import dct, idct, next_fast_len
label_desc: Use image node_id 3 for calling the DCTAdam obj's underlying member method code with example usage: obj._step_param(group, p) without return types