code: def test_early_stopping():
      test_data = _get_test_data()
  
      net = _get_test_network()
      ce_loss = loss.SoftmaxCrossEntropyLoss()
      acc = mx.gluon.metric.Accuracy()
      est = estimator.Estimator(net, loss=ce_loss, train_metrics=acc)
      early_stopping = event_handler.EarlyStoppingHandler(
          monitor=acc, patience=0, mode="min"
      )
      est.fit(test_data, event_handlers=[early_stopping], epochs=5)
      assert early_stopping.current_epoch == 2
      assert early_stopping.stopped_epoch == 1
  
      early_stopping = event_handler.EarlyStoppingHandler(
          monitor=acc, patience=2, mode="auto"
      )
      est.fit(test_data, event_handlers=[early_stopping], epochs=1)
      assert early_stopping.current_epoch == 1
  
imports: import os
  import logging
  import sys
  import re
  import mxnet
  from common import TemporaryDirectory
  from mxnet import np
  from mxnet.gluon import nn, loss
  from mxnet.gluon.contrib.estimator import estimator, event_handler
  from mxnet.gluon.contrib.estimator.event_handler import LoggingHandler
  from mxnet.gluon.contrib.estimator.event_handler import ValidationHandler
  from mxnet.gluon.contrib.estimator import EpochEnd
  from mxnet.gluon.data.dataset import Dataset
label_desc: Use image node_id 6 for calling a global function with example usage: test_early_stopping() without return types