code: def test_default_handlers():
      net = _get_test_network()
      train_data, _ = _get_test_data()
  
      num_epochs = 1
      device = mx.cpu()
  
      net.initialize(device=device)
      trainer = gluon.Trainer(
          net.collect_params(), "sgd", {"learning_rate": 0.001}
      )
  
      train_acc = mx.gluon.metric.RMSE()
      loss = gluon.loss.L2Loss()
  
      est = Estimator(
          net=net,
          loss=loss,
          train_metrics=train_acc,
          trainer=trainer,
          device=device,
      )
      # no handler(all default handlers), no warning
      with warnings.catch_warnings(record=True) as w:
          est.fit(train_data=train_data, epochs=num_epochs)
  
      # handler with prepared loss and metrics
      # use mix of default and user defined handlers
      train_metrics = est.train_metrics
      val_metrics = est.val_metrics
      logging = LoggingHandler(metrics=train_metrics)
      est.fit(
          train_data=train_data,
          epochs=num_epochs,
          event_handlers=[logging],
      )
  
      # handler with all user defined metrics
      # use mix of default and user defined handlers
      metric = MetricHandler(metrics=[train_acc])
      logging = LoggingHandler(metrics=[train_acc])
      est.fit(
          train_data=train_data,
          epochs=num_epochs,
          event_handlers=[metric, logging],
      )
  
      # handler with mixed metrics, some handler use metrics prepared by estimator
      # some handler use metrics user prepared
      logging = LoggingHandler(
          metrics=[mx.gluon.metric.RMSE("val acc")]
      )
      with pytest.raises(ValueError):
          est.fit(
              train_data=train_data,
              epochs=num_epochs,
              event_handlers=[logging],
          )
  
      # test handler order
      train_metrics = est.train_metrics
      val_metrics = est.val_metrics
      early_stopping = EarlyStoppingHandler(monitor=val_metrics[0])
      handlers = est._prepare_default_handlers(
          val_data=None, event_handlers=[early_stopping]
      )
      assert len(handlers) == 5
      assert isinstance(handlers[0], GradientUpdateHandler)
      assert isinstance(handlers[1], MetricHandler)
      assert isinstance(handlers[4], LoggingHandler)
  
imports: import sys
  import unittest
  import warnings
  import pytest
  import mxnet
  from mxnet import gluon
  from mxnet.gluon import nn
  from mxnet.gluon.contrib.estimator import *
  from mxnet.gluon.contrib.estimator.event_handler import *
label_desc: Use image node_id 11 for calling a global function with example usage: test_default_handlers() without return types