def test_lr_scheduler_step_not_called(tmp_path):
    """Test `lr_scheduler.step()` is not called in manual optimization."""
    model = ManualOptimBoringModel()
    trainer = Trainer(max_epochs=1, default_root_dir=tmp_path, fast_dev_run=2)

    with patch("torch.optim.lr_scheduler.StepLR.step") as lr_step:
        trainer.fit(model)

    # If a lr scheduler inherits `torch.optim.lr_scheduler.LRScheduler`,
    # `.step()` is called once during its instantiation.
    # Thus, the call count should be 1, not 0.
    assert lr_step.call_count == 1
Test `lr_scheduler.step()` is not called in manual optimization.
tests/tests_pytorch/trainer/optimization/test_manual_optimization.py