code: def test_optimizer_return_options(tmpdir):
      trainer = Trainer(default_root_dir=tmpdir)
      model = BoringModel()
      trainer.strategy.connect(model)
      trainer.lightning_module.trainer = trainer
  
      # single optimizer
      opt_a = optim.Adam(model.parameters(), lr=0.002)
      opt_b = optim.SGD(model.parameters(), lr=0.002)
      scheduler_a = optim.lr_scheduler.StepLR(opt_a, 10)
      optim.lr_scheduler.StepLR(opt_b, 10)
  
      # single optimizer
      model.configure_optimizers = lambda: opt_a
      opt, lr_sched = _init_optimizers_and_lr_schedulers(model)
      assert len(opt) == 1
      assert len(lr_sched) == 0
  
      # opt tuple
      model.automatic_optimization = False
      model.configure_optimizers = lambda: (opt_a, opt_b)
      opt, lr_sched = _init_optimizers_and_lr_schedulers(model)
      assert opt == [opt_a, opt_b]
      assert len(lr_sched) == 0
  
      # opt list
      model.automatic_optimization = False
      model.configure_optimizers = lambda: [opt_a, opt_b]
      opt, lr_sched = _init_optimizers_and_lr_schedulers(model)
      assert opt == [opt_a, opt_b]
      assert len(lr_sched) == 0
  
      ref_lr_sched = LRSchedulerConfig(
          scheduler=scheduler_a,
          interval="epoch",
          frequency=1,
          reduce_on_plateau=False,
          monitor=None,
          strict=True,
          name=None,
      )
  
      # opt tuple of 2 lists
      model.automatic_optimization = True
      model.configure_optimizers = lambda: ([opt_a], [scheduler_a])
      opt, lr_sched = _init_optimizers_and_lr_schedulers(model)
      assert len(opt) == len(lr_sched) == 1
      assert opt[0] == opt_a
      assert lr_sched[0] == ref_lr_sched
  
      # opt tuple of 1 list
      model.automatic_optimization = True
      model.configure_optimizers = lambda: ([opt_a], scheduler_a)
      opt, lr_sched = _init_optimizers_and_lr_schedulers(model)
      assert len(opt) == len(lr_sched) == 1
      assert opt[0] == opt_a
      assert lr_sched[0] == ref_lr_sched
  
      # opt single dictionary
      model.automatic_optimization = True
      model.configure_optimizers = lambda: {
          "optimizer": opt_a,
          "lr_scheduler": scheduler_a,
      }
      opt, lr_sched = _init_optimizers_and_lr_schedulers(model)
      assert len(opt) == len(lr_sched) == 1
      assert opt[0] == opt_a
      assert lr_sched[0] == ref_lr_sched
  
imports: from unittest import mock
  from unittest.mock import call
  import pytest
  import torch
  from lightning.pytorch import Trainer
  from lightning.pytorch.callbacks import ModelCheckpoint
  from lightning.pytorch.core.optimizer import _configure_optimizers, _configure_schedulers_automatic_opt, _init_optimizers_and_lr_schedulers
  from lightning.pytorch.demos.boring_classes import BoringDataModule, BoringModel
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.types import LRSchedulerConfig
  from torch import optim
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 8 for calling a global function with example usage: test_optimizer_return_options(tmpdir) without return types