code: def step(self, closure=None):
      loss = None
      if closure is not None:
          with torch.enable_grad():
              loss = closure()
      for group in self.param_groups:
          for p in group["params"]:
              if p.grad is None:
                  continue
              grad = p.grad
              state = self.state[p]
              clr = group["lr"]
              momentum = group["momentum"]
              if grad.is_sparse:
                  grad = grad.coalesce()
                  grad_indices = grad._indices()[0]
                  grad_values = grad._values()
                  accs = state["acc"][grad_indices] + grad_values.pow(2)
                  state["acc"].index_copy_(0, grad_indices, accs)
                  accs.add_(group["eps"]).sqrt_().mul_(-1 / clr)
                  if momentum > 0:
                      moma = state["mom"][grad_indices]
                      moma.mul_(momentum).add_(grad_values / accs)
                      state["mom"].index_copy_(0, grad_indices, moma)
                      p.index_add_(0, grad_indices, moma)
                  else:
                      p.index_add_(0, grad_indices, grad_values / accs)
              else:
                  state["acc"].add_(grad.pow(2))
                  accs = state["acc"].add(group["eps"])
                  accs.sqrt_()
                  if momentum > 0:
                      mom = state["mom"]
                      mom.mul_(momentum).addcdiv_(
                          grad, accs, value=-clr
                      )
                      p.add_(mom)
                  else:
                      p.addcdiv_(grad, accs, value=-clr)
      return loss
  
imports: from collections import Counter
  import numpy
  import torch
  from torch import nn
  from torch.autograd import Variable
  from torch.optim import Optimizer
  from cornac.utils.common import get_rng
label_desc: Use image node_id 3 for calling the IndexedAdagradM obj's underlying member method code with example usage: obj.step(closure) and returns: loss