class_docstr: Implements Lookahead optimization algorithm.
  
  It has been proposed in `Lookahead Optimizer: k steps forward, 1
  step back`__
  
  Arguments:
      optimizer: base inner optimizer optimize, like Yogi, DiffGrad or Adam.
      k: number of lookahead steps (default: 5)
      alpha: linear interpolation factor. 1.0 recovers the inner optimizer.
          (default: 5)
  
  Example:
      >>> import torch_optimizer as optim
      >>> yogi = optim.Yogi(model.parameters(), lr=0.1)
      >>> optimizer = optim.Lookahead(yogi, k=5, alpha=0.5)
      >>> optimizer.zero_grad()
      >>> loss_fn(model(input), target).backward()
      >>> optimizer.step()
  
  __ https://arxiv.org/abs/1907.08610
  
  Note:
      Reference code: https://github.com/alphadl/lookahead.pytorch
docstr: Performs a single optimization step.
  
  Arguments:
      closure: A closure that reevaluates the model and returns the loss.
docstr_tok: ["Performs","a","single","optimization","step",".","Arguments",":","closure",":","A","closure","that","reevaluates","the","model","and","returns","the","loss","."]
code: def step(self, closure: OptLossClosure = None) -> OptFloat:
      r"""Performs a single optimization step.
  
      Arguments:
          closure: A closure that reevaluates the model and returns the loss.
      """
      loss = self.optimizer.step(closure=closure)
      for group in self.param_groups:
          if group["counter"] == 0:
              self._update(group)
          group["counter"] += 1
          group["counter"] %= self.k
      return loss
  
file_path: pytorch-optimizer/torch_optimizer/lookahead.py
imports: from collections import defaultdict
  from typing import Any, Dict
  import torch
  from torch.optim.optimizer import Optimizer
  from .types import OptFloat, OptLossClosure, State
label_desc: Use image node_id 3 for calling the Lookahead obj's underlying member method code with example usage: obj.step(closure) and returns: loss