code: def extract_lr_from_optimizer(
      optim: torch.optim.Optimizer, prefix: str
  ) -> Dict[str, float]:
      """
      Retrieves the learning rate values from an optimizer and returns them as a dictionary.
      """
      lr_stats = {}
      seen_pg_keys = {}
      for pg in optim.param_groups:
          lr = pg["lr"]
          name = _get_deduped_name(seen_pg_keys, pg.get("name", "pg"))
          key = f"{prefix}/{name}"
          assert key not in lr_stats
          lr_stats[key] = lr
      return lr_stats
  
imports: from typing import Dict
  import torch
label_desc: Use image node_id 2 for calling a global function with example usage: extract_lr_from_optimizer(optim, prefix) and returns: lr_stats