docstr: Recursively parses the output of :meth:`lightning.pytorch.LightningModule.configure_optimizers`.
  
  Args:
      configure_optim_output: The output of ``configure_optimizers``.
          For supported values, please refer to :meth:`lightning.pytorch.LightningModule.configure_optimizers`.
docstr_tok: ["Recursively","parses","the","output","of",":","meth",":","`","lightning.pytorch.LightningModule.configure_optimizers","`",".","Args",":","configure_optim_output",":","The","output","of","``","configure_optimizers","``",".","For","supported","values",",","please","refer","to",":","meth",":","`","lightning.pytorch.LightningModule.configure_optimizers","`","."]
code: def _parse_optimizers_schedulers(
      self, configure_optim_output
  ) -> Tuple[
      Optional[L.fabric.utilities.types.Optimizable],
      Optional[
          Mapping[
              str,
              Union[
                  L.fabric.utilities.types.LRScheduler, bool, str, int
              ],
          ]
      ],
  ]:
      """Recursively parses the output of :meth:`lightning.pytorch.LightningModule.configure_optimizers`.
  
      Args:
          configure_optim_output: The output of ``configure_optimizers``.
              For supported values, please refer to :meth:`lightning.pytorch.LightningModule.configure_optimizers`.
  
      """
      _lr_sched_defaults = {
          "interval": "epoch",
          "frequency": 1,
          "monitor": "val_loss",
      }
  
      # single optimizer
      if isinstance(
          configure_optim_output, L.fabric.utilities.types.Optimizable
      ):
          return configure_optim_output, None
  
      # single lr scheduler
      if isinstance(
          configure_optim_output, L.fabric.utilities.types.LRScheduler
      ):
          return None, _lr_sched_defaults.update(
              scheduler=configure_optim_output
          )
  
      # single lr scheduler config
      if isinstance(configure_optim_output, Mapping):
          _lr_sched_defaults.update(configure_optim_output)
          return None, _lr_sched_defaults
  
      # list or tuple
      if isinstance(configure_optim_output, (list, tuple)):
          if all(
              isinstance(
                  _opt_cand, L.fabric.utilities.types.Optimizable
              )
              for _opt_cand in configure_optim_output
          ):
              # single optimizer in list
              if len(configure_optim_output) == 1:
                  return configure_optim_output[0][0], None
  
              raise NotImplementedError(
                  "BYOT only supports a single optimizer"
              )
  
          if all(
              isinstance(
                  _lr_cand,
                  (L.fabric.utilities.types.LRScheduler, Mapping),
              )
              for _lr_cand in configure_optim_output
          ):
              # single scheduler in list
              if len(configure_optim_output) == 1:
                  return (
                      None,
                      self._parse_optimizers_schedulers(
                          configure_optim_output[0]
                      )[1],
                  )
  
          # optimizer and lr scheduler
          elif len(configure_optim_output) == 2:
              opt_cands, lr_cands = (
                  self._parse_optimizers_schedulers(
                      configure_optim_output[0]
                  )[0],
                  self._parse_optimizers_schedulers(
                      configure_optim_output[1]
                  )[1],
              )
              return opt_cands, lr_cands
  
      return None, None
  
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 12 for calling the MyCustomTrainer obj's underlying member method code with example usage: obj._parse_optimizers_schedulers(configure_optim_output) and returns: None,  None, configure_optim_output,  None, None,  _lr_sched_defaults, None,  _lr_sched_defaults, configure_optim_output,  None, None,  self, opt_cands,  lr_cands