code: def test_reduce_lr_on_plateau_scheduler():
      tensor1 = torch.zeros([1], requires_grad=True)
      tensor2 = torch.zeros([1], requires_grad=True)
      optimizer = torch.optim.SGD(
          [{"params": [tensor1]}, {"params": [tensor2]}], lr=1
      )
  
      data = [0] * 8
      max_epochs = 10
  
      trainer = Engine(lambda engine, batch: None)
  
      @trainer.on(Events.EPOCH_COMPLETED)
      def evaluate():
          evaluator.run(data)
  
      scheduler = ReduceLROnPlateauScheduler(
          optimizer,
          metric_name="acc",
          mode="max",
          factor=0.5,
          patience=1,
          threshold_mode="abs",
          threshold=1.99,
          min_lr=1e-7,
          save_history=True,
          trainer=trainer,
          param_group_index=0,
      )
      evaluator = Engine(lambda engine, batch: None)
      evaluator.state.metrics = {"acc": 0.0}
      generate_acc = iter([3, 7, 7, 9, 10, 11, 8, 8, 4, 7])
  
      @evaluator.on(Events.COMPLETED)
      def set_acc():
          evaluator.state.metrics["acc"] = next(generate_acc)
  
      evaluator.add_event_handler(Events.COMPLETED, scheduler)
  
      trainer.run(data, max_epochs=max_epochs)
  
      lrs = [param[0] for param in trainer.state.param_history["lr"]]
      assert lrs == list(
          map(
              pytest.approx,
              [1, 1, 1, 1, 1, 1, 1, 0.5, 0.5, 0.25],
          )
      )
      assert optimizer.param_groups[1]["lr"] == 1
  
      values = ReduceLROnPlateauScheduler.simulate_values(
          5,
          [10, 9, 9, 9, 8.1],
          1.0,
          save_history=True,
          factor=0.5,
          patience=2,
          threshold=0.1,
      )
      values = np.array(values)[:, 1].tolist()
      assert values == list(
          map(
              pytest.approx,
              [1.0, 1.0, 1.0, 0.5, 0.5],
          )
      )
  
imports: from unittest.mock import MagicMock, patch
  import numpy
  import pytest
  import torch
  from torch.optim.lr_scheduler import CosineAnnealingWarmRestarts, ExponentialLR, StepLR
  from ignite.engine import Engine, Events
  from ignite.handlers.param_scheduler import ConcatScheduler, CosineAnnealingScheduler, create_lr_scheduler_with_warmup, LinearCyclicalScheduler, LRScheduler, ParamGroupScheduler, ParamScheduler, PiecewiseLinear, ReduceLROnPlateauScheduler
  from tests.ignite.contrib.handlers import MockFP16DeepSpeedZeroOptimizer
label_desc: Use image node_id 25 for calling a global function with example usage: test_reduce_lr_on_plateau_scheduler() without return types