def _init_optimizers_and_lr_schedulers(
    model: "pl.LightningModule",
) -> tuple[list[Optimizer], list[LRSchedulerConfig]]:
    """Calls `LightningModule.configure_optimizers` and parses and validates the output."""
    from lightning.pytorch.trainer import call

    optim_conf = call._call_lightning_module_hook(model.trainer, "configure_optimizers", pl_module=model)

    if optim_conf is None:
        rank_zero_warn(
            "`LightningModule.configure_optimizers` returned `None`, this fit will run with no optimizer",
        )
        optim_conf = _MockOptimizer()

    optimizers, lr_schedulers, monitor = _configure_optimizers(optim_conf)
    lr_scheduler_configs = (
        _configure_schedulers_automatic_opt(lr_schedulers, monitor)
        if model.automatic_optimization
        else _configure_schedulers_manual_opt(lr_schedulers)
    )
    _validate_multiple_optimizers_support(optimizers, model)
    _validate_optimizers_attached(optimizers, lr_scheduler_configs)
    _validate_scheduler_api(lr_scheduler_configs, model)
    return optimizers, lr_scheduler_configs
Calls `LightningModule.configure_optimizers` and parses and validates the output.
src/lightning/pytorch/core/optimizer.py