def METHOD_NAME(self, closure=None):
    """Performs a single optimization step.
    Arguments:
        closure (callable, optional): A closure that reevaluates the model
            and returns the loss.
    """
    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
            if grad.is_sparse:
                raise RuntimeError('RMSprop does not support sparse gradients')
            state = self.state[p]
            # State initialization
            if len(state) == 0:
                state['step'] = 0
                state['square_avg'] = torch.ones_like(p)  # PyTorch inits to zero
                if group['momentum'] > 0:
                    state['momentum_buffer'] = torch.zeros_like(p)
                if group['centered']:
                    state['grad_avg'] = torch.zeros_like(p)
            square_avg = state['square_avg']
            one_minus_alpha = 1. - group['alpha']
            state['step'] += 1
            if group['weight_decay'] != 0:
                if group['decoupled_decay']:
                    p.mul_(1. - group['lr'] * group['weight_decay'])
                else:
                    grad = grad.add(p, alpha=group['weight_decay'])
            # Tensorflow order of ops for updating squared avg
            square_avg.add_(grad.pow(2) - square_avg, alpha=one_minus_alpha)
            # square_avg.mul_(alpha).addcmul_(grad, grad, value=1 - alpha)  # PyTorch original
            if group['centered']:
                grad_avg = state['grad_avg']
                grad_avg.add_(grad - grad_avg, alpha=one_minus_alpha)
                avg = square_avg.addcmul(grad_avg, grad_avg, value=-1).add(group['eps']).sqrt_()  # eps in sqrt
                # grad_avg.mul_(alpha).add_(grad, alpha=1 - alpha)  # PyTorch original
            else:
                avg = square_avg.add(group['eps']).sqrt_()  # eps moved in sqrt
            if group['momentum'] > 0:
                buf = state['momentum_buffer']
                # Tensorflow accumulates the LR scaling in the momentum buffer
                if group['lr_in_momentum']:
                    buf.mul_(group['momentum']).addcdiv_(grad, avg, value=group['lr'])
                    p.add_(-buf)
                else:
                    # PyTorch scales the param update by LR
                    buf.mul_(group['momentum']).addcdiv_(grad, avg)
                    p.add_(buf, alpha=-group['lr'])
            else:
                p.addcdiv_(grad, avg, value=-group['lr'])
    return loss