docstr: Steps the learning rate scheduler if necessary.
  
  Args:
      model: The LightningModule to train
      scheduler_cfg: The learning rate scheduler configuration.
          Have a look at :meth:`lightning.pytorch.LightningModule.configure_optimizers` for supported values.
      level: whether we are trying to step on epoch- or step-level
      current_value: Holds the current_epoch if ``level==epoch``, else holds the ``global_step``
docstr_tok: ["Steps","the","learning","rate","scheduler","if","necessary",".","Args",":","model",":","The","LightningModule","to","train","scheduler_cfg",":","The","learning","rate","scheduler","configuration",".","Have","a","look","at",":","meth",":","`","lightning.pytorch.LightningModule.configure_optimizers","`","for","supported","values",".","level",":","whether","we","are","trying","to","step","on","epoch-","or","step-level","current_value",":","Holds","the","current_epoch","if","``","level==epoch","``",",","else","holds","the","``","global_step","``"]
code: def step_scheduler(
      self,
      model: L.LightningModule,
      scheduler_cfg: Optional[
          Mapping[
              str,
              Union[
                  L.fabric.utilities.types.LRScheduler, bool, str, int
              ],
          ]
      ],
      level: Literal["step", "epoch"],
      current_value: int,
  ) -> None:
      """Steps the learning rate scheduler if necessary.
  
      Args:
          model: The LightningModule to train
          scheduler_cfg: The learning rate scheduler configuration.
              Have a look at :meth:`lightning.pytorch.LightningModule.configure_optimizers` for supported values.
          level: whether we are trying to step on epoch- or step-level
          current_value: Holds the current_epoch if ``level==epoch``, else holds the ``global_step``
  
      """
  
      # no scheduler
      if scheduler_cfg is None:
          return
  
      # wrong interval (step vs. epoch)
      if scheduler_cfg["interval"] != level:
          return
  
      # right interval, but wrong step wrt frequency
      if current_value % cast(int, scheduler_cfg["frequency"]) != 0:
          return
  
      # assemble potential monitored values
      possible_monitor_vals = {None: None}
      if isinstance(self._current_train_return, torch.Tensor):
          possible_monitor_vals.update(
              "train_loss", self._current_train_return
          )
      elif isinstance(self._current_train_return, Mapping):
          possible_monitor_vals.update(
              {
                  "train_" + k: v
                  for k, v in self._current_train_return.items()
              }
          )
  
      if isinstance(self._current_val_return, torch.Tensor):
          possible_monitor_vals.update(
              "val_loss", self._current_val_return
          )
      elif isinstance(self._current_val_return, Mapping):
          possible_monitor_vals.update(
              {
                  "val_" + k: v
                  for k, v in self._current_val_return.items()
              }
          )
  
      try:
          monitor = possible_monitor_vals[
              cast(Optional[str], scheduler_cfg["monitor"])
          ]
      except KeyError as ex:
          possible_keys = list(possible_monitor_vals.keys())
          raise KeyError(
              f"monitor {scheduler_cfg['monitor']} is invalid. Possible values are {possible_keys}."
          ) from ex
  
      # rely on model hook for actual step
      model.lr_scheduler_step(scheduler_cfg["scheduler"], monitor)
  
imports: import os
  from collections.abc import Mapping
  from functools import partial
  from typing import Any, Iterable, List, Literal, Optional, Tuple, Union, cast
  import lightning
  import torch
  from lightning.fabric.accelerators import Accelerator
  from lightning.fabric.loggers import Logger
  from lightning.fabric.strategies import Strategy
  from lightning.fabric.wrappers import _unwrap_objects
  from lightning.pytorch.utilities.model_helpers import is_overridden
  from lightning_utilities import apply_to_collection
  from tqdm import tqdm
label_desc: Use image node_id 6 for calling the MyCustomTrainer obj's underlying member method code with example usage: obj.step_scheduler(model, scheduler_cfg, level, current_value) without return types