def test_reducelronplateau_with_no_monitor_in_lr_scheduler_dict_raises(tmp_path):
    """Test exception when lr_scheduler dict has a ReduceLROnPlateau with no monitor."""
    model = BoringModel()
    optimizer = optim.Adam(model.parameters())
    model.configure_optimizers = lambda: {
        "optimizer": optimizer,
        "lr_scheduler": {"scheduler": optim.lr_scheduler.ReduceLROnPlateau(optimizer)},
    }
    trainer = Trainer(default_root_dir=tmp_path, fast_dev_run=True)
    with pytest.raises(MisconfigurationException, match="must include a monitor when a `ReduceLROnPlateau`"):
        trainer.fit(model)
Test exception when lr_scheduler dict has a ReduceLROnPlateau with no monitor.
tests/tests_pytorch/trainer/optimization/test_optimizers.py