class_docstr: EarlyStopping handler can be used to stop the training if no improvement after a given number of events.
  
  Args:
      patience: Number of events to wait if no improvement and then stop the training.
      score_function: It should be a function taking a single argument, an :class:`~ignite.engine.engine.Engine`
          object, and return a score `float`. An improvement is considered if the score is higher.
      trainer: Trainer engine to stop the run if no improvement.
      min_delta: A minimum increase in the score to qualify as an improvement,
          i.e. an increase of less than or equal to `min_delta`, will count as no improvement.
      cumulative_delta: It True, `min_delta` defines an increase since the last `patience` reset, otherwise,
          it defines an increase after the last event. Default value is False.
  
  Examples:
      .. code-block:: python
  
          from ignite.engine import Engine, Events
          from ignite.handlers import EarlyStopping
  
          def score_function(engine):
              val_loss = engine.state.metrics['nll']
              return -val_loss
  
          handler = EarlyStopping(patience=10, score_function=score_function, trainer=trainer)
          # Note: the handler is attached to an *Evaluator* (runs one epoch on validation dataset).
          evaluator.add_event_handler(Events.COMPLETED, handler)
code: def __call__(self, engine: Engine) -> None:
      score = self.score_function(engine)
  
      if self.best_score is None:
          self.best_score = score
      elif score <= self.best_score + self.min_delta:
          if not self.cumulative_delta and score > self.best_score:
              self.best_score = score
          self.counter += 1
          self.logger.debug(
              "EarlyStopping: %i / %i" % (self.counter, self.patience)
          )
          if self.counter >= self.patience:
              self.logger.info("EarlyStopping: Stop training")
              self.trainer.terminate()
      else:
          self.best_score = score
          self.counter = 0
  
file_path: ignite/ignite/handlers/early_stopping.py
imports: from collections import OrderedDict
  from typing import Callable, cast, Mapping, Optional
  from ignite.base import Serializable
  from ignite.engine import Engine
  from ignite.utils import setup_logger
label_desc: Use image node_id 2 for calling the EarlyStopping obj's underlying member method code with example usage: obj.__call__(engine) without return types