code: def test_callbacks():
      n_epochs = 4
  
      history = TrainingHistory()
      iter_avg = ModelIterationAveraging(
          avg_strategy=NTA(epochs=2 * n_epochs)
      )
  
      dataset = "m4_hourly"
      dataset = get_dataset(dataset)
      prediction_length = dataset.metadata.prediction_length
  
      estimator = SimpleFeedForwardEstimator(
          prediction_length=prediction_length,
          trainer=Trainer(
              epochs=n_epochs, callbacks=[history, iter_avg]
          ),
      )
  
      predictor = estimator.train(dataset.train, num_workers=None)
  
      assert len(history.loss_history) == n_epochs
  
      ws = WarmStart(predictor=predictor)
  
      estimator = SimpleFeedForwardEstimator(
          prediction_length=prediction_length,
          trainer=Trainer(
              epochs=n_epochs, callbacks=[history, iter_avg, ws]
          ),
      )
      predictor = estimator.train(dataset.train, num_workers=None)
  
      assert len(history.loss_history) == n_epochs * 2
  
imports: from gluonts.mx.trainer import Trainer
  from gluonts.mx.trainer.callback import CallbackList, TerminateOnNaN, WarmStart, TrainingHistory
  from gluonts.mx.trainer.model_iteration_averaging import NTA, ModelIterationAveraging
  from gluonts.dataset.repository import get_dataset
  from gluonts.mx import SimpleFeedForwardEstimator
label_desc: Use image node_id 2 for calling a global function with example usage: test_callbacks() without return types