class_docstr: A callback which logs learning rate of tracked optimizers and learning rate schedulers.
  Logs learning rate for each parameter group associated with an optimizer.
  
  Args:
      loggers: Either a :class:`torchtnt.loggers.logger.MetricLogger` or
          list of :class:`torchtnt.loggers.logger.MetricLogger`
class_docstr_tok: ["A","callback","which","logs","learning","rate","of","tracked","optimizers","and","learning","rate","schedulers",".","Logs","learning","rate","for","each","parameter","group","associated","with","an","optimizer",".","Args",":","loggers",":","Either","a",":","class",":","`","torchtnt.loggers.logger.MetricLogger","`","or","list","of",":","class",":","`","torchtnt.loggers.logger.MetricLogger","`"]
docstr: Extracts learning rates from optimizers and LR schedulers and returns them as a dictionary.
docstr_tok: ["Extracts","learning","rates","from","optimizers","and","LR","schedulers","and","returns","them","as","a","dictionary","."]
code: def _extract_lr(cls, unit: TTrainUnit) -> Dict[str, float]:
      """
      Extracts learning rates from optimizers and LR schedulers and returns them as a dictionary.
      """
      lr_stats: Dict[str, float] = {}
  
      # go through tracked optimizers
      optimizers = unit.tracked_optimizers()
      for name, optim in optimizers.items():
          lr_stats.update(
              extract_lr_from_optimizer(optim, f"optimizers/{name}")
          )
  
      # go through tracked LR schedulers
      lr_schedulers = unit.tracked_lr_schedulers()
      for name, lr_scheduler in lr_schedulers.items():
          lr_stats.update(
              extract_lr_from_optimizer(
                  lr_scheduler.optimizer, f"lr_schedulers/{name}"
              )
          )
  
      return lr_stats
  
file_path: tnt/torchtnt/framework/callbacks/learning_rate_monitor.py
imports: from typing import Dict, List, Union
  from torchtnt.framework.callback import Callback
  from torchtnt.framework.state import State
  from torchtnt.framework.unit import TTrainUnit
  from torchtnt.utils.loggers.logger import MetricLogger
  from torchtnt.utils.optimizer import extract_lr_from_optimizer
label_desc: Use image node_id 4 for calling the LearningRateMonitor obj's underlying member method code with example usage: obj._extract_lr(cls, unit) and returns: lr_stats