code: def test_simple_early_stopping_on_plateau():
      def score_function(engine):
          return 42
  
      trainer = Engine(do_nothing_update_fn)
  
      h = EarlyStopping(
          patience=1, score_function=score_function, trainer=trainer
      )
      # Call 2 times and check if stopped
      assert not trainer.should_terminate
      h(None)
      assert not trainer.should_terminate
      h(None)
      assert trainer.should_terminate
  
imports: import os
  import pytest
  import torch
  import ignite.distributed
  from ignite.engine import Engine, Events
  from ignite.handlers import EarlyStopping
label_desc: Use image node_id 8 for calling a global function with example usage: test_simple_early_stopping_on_plateau() and returns: int