code: def test_invalid_scheduler_missing_state_dict():
      """Test that custom lr scheduler raises an error if it's missing the state dict."""
  
      class CustomScheduler:
          def __init__(self, optimizer):
              self.optimizer = optimizer
  
          def step(self):
              ...
  
      class CustomBoringModel(BoringModel):
          def configure_optimizers(self):
              opt = torch.optim.SGD(self.parameters(), lr=1e-2)
              lr_scheduler = CustomScheduler(opt)
              return {"optimizer": opt, "lr_scheduler": lr_scheduler}
  
      model = CustomBoringModel()
      model.trainer = Trainer()
      with pytest.raises(
          TypeError,
          match="provided lr scheduler `CustomScheduler` is invalid",
      ):
          _init_optimizers_and_lr_schedulers(model)
  
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 26 for calling a global function with example usage: test_invalid_scheduler_missing_state_dict() and returns: dict