code: def store_optimizer_indicators(
      optimizer: "Optimizer",
      *,
      models: Optional[Dict[str, torch.nn.Module]] = None,
      optimizer_name: str = "optimizer",
  ):
      """
      Track optimizer stats such as moments.
  
      Arguments:
          optimizer (Optimizer): PyTorch optimizer
  
      Keyword Arguments:
          models (Dict[str, torch.nn.Module], optional): a dictionary of modules being optimized.
              This is used to get the proper parameter names.
          optimizer_name (str, optional): name of the optimizer
      """
  
      if models is None:
          models = {}
      names = {}
      for model_name, model in models.items():
          for name, p in model.named_parameters():
              names[p] = f"{model_name}.{name}"
  
      unknown = 0
      for group in optimizer.param_groups:
          for p in group["params"]:
              if p.grad is None:
                  continue
              state = optimizer.state[p]
              if len(state) == 0:
                  continue
  
              name = names.get(p, None)
              if name is None:
                  name = f"unknown.{unknown}"
                  unknown += 1
  
              for k, v in state.items():
                  if isinstance(v, float) or isinstance(v, int):
                      tracker.add(
                          f"optim.{optimizer_name}.{name}.{k}", v
                      )
                  if isinstance(v, torch.Tensor):
                      store_l1_l2(
                          f"optim.{optimizer_name}.{name}.{k}", v
                      )
  
file_path: labml/client/labml/utils/pytorch.py
imports: from typing import Optional, Dict, TYPE_CHECKING
  import torch
  from labml import tracker
  from labml.configs import BaseConfigs
label_desc: Use image node_id 4 for calling a global function with example usage: store_optimizer_indicators(optimizer) without return types