class_docstr: TestCallback
code: def test_earlystopping(self):
      trainer_control = TrainerControl()
      earlystopping_callback = EarlyStoppingCallback(
          trainer_control, "loss", patience=3, mode="min"
      )
  
      loss_value = [
          5.0,
          4.0,
          3.0,
          2.5,
          2.1,
          2.0,
          2.0,
          2.0,
          2.0,
          2.0,
          2.0,
      ]
  
      def loss_emulator():
          for value in loss_value:
              yield value
  
      train_log = {}
      earlystopping_callback.on_train_begin(train_log)
      for epoch, loss_value in enumerate(loss_emulator()):
          train_log["loss"] = loss_value
          earlystopping_callback.on_epoch_end(epoch, train_log)
      earlystopping_callback.on_train_end(train_log)
      assert (
          earlystopping_callback.trainercontrol.should_training_stop
          is True
      )
  
file_path: towhee/tests/unittests/trainer/test_callback.py
imports: import unittest
  from typing import Dict, Tuple
  from tqdm import tqdm
  from towhee.trainer.callback import TrainerControl, Callback, CallbackList, EarlyStoppingCallback, ModelCheckpointCallback, TensorBoardCallBack, PrintCallBack, ProgressBarCallBack
label_desc: Use image node_id 4 for calling the TestCallback obj's underlying member method code with example usage: obj.test_earlystopping() without return types