class_docstr: A wrapper class for existing PyTorch optimizers
class_docstr_tok: ["A","wrapper","class","for","existing","PyTorch","optimizers"]
code: def __init__(
      self,
      params: Tensor
      | Iterable = None,  # Model parameters. Don't set if using a built optimizer
      opt: callable
      | torch.optim.Optimizer = None,  # A torch optimizer constructor, or an already built optimizer
      hp_map: dict = None,  # A dictionary converting PyTorch optimizer keys to fastai's `Optimizer` keys. Defaults to `pytorch_hp_map`
      convert_groups: bool = True,  # Convert parameter groups from splitter or pass unaltered to `opt`
      **kwargs,
  ):
      if params is None and opt is None:
          raise ValueError("Both `params` and `opt` cannot be None.")
      if callable(opt):
          if convert_groups:
              params = L(params)
              convert_groups = isinstance(params[0], (L, list))
          self.opt = (
              opt(_convert_params(params), **kwargs)
              if convert_groups
              else opt(params, **kwargs)
          )
      else:
          if params is not None:
              raise ValueError(
                  "Tried using both `params` and a built optimizer. Just pass in `opt`."
              )
          self.opt = opt
      if hp_map is None:
          hp_map = pytorch_hp_map
      self.fwd_map = {
          k: hp_map[k] if k in hp_map else k
          for k in detuplify_pg(self.opt.param_groups[0]).keys()
      }
      self.bwd_map = {v: k for k, v in self.fwd_map.items()}
      self.state = defaultdict(dict, {})
      self.frozen_idx = 0
  
imports: from __future__ import annotations
  from .torch_basics import *
label_desc: Use image node_id 1 to create a new OptimWrapper object from inherited base classes: _BaseOptimizer, GetAttr with example: obj = OptimWrapper(params, opt, hp_map, convert_groups)