code: def test_logging_interval():
      """test different options for logging handler"""
      """ test case #1: log interval is 1 """
      batch_size = 8
      data_size = 100
      old_stdout = sys.stdout
      sys.stdout = mystdout = StringIO()
      log_interval = 1
      net = _get_test_network()
      dataloader = _get_test_data(in_size=data_size)
      num_epochs = 1
      ce_loss = loss.SoftmaxCrossEntropyLoss()
      acc = mx.gluon.metric.Accuracy()
      logging = LoggingHandler(metrics=[acc], log_interval=log_interval)
      est = estimator.Estimator(
          net=net, loss=ce_loss, train_metrics=acc
      )
  
      est.fit(
          train_data=dataloader,
          epochs=num_epochs,
          event_handlers=[logging],
      )
  
      sys.stdout = old_stdout
      log_info_list = mystdout.getvalue().splitlines()
      info_len = 0
      for info in log_info_list:
          match = re.match(
              r"(\[Epoch \d+\]\[Batch \d+\]\[Samples \d+\] time\/interval: \d+.\d+s"
              + r" training accuracy: \d+.\d+)",
              info,
          )
          if match:
              info_len += 1
  
      assert info_len == int(data_size / batch_size / log_interval) + 1
      """ test case #2: log interval is 5 """
      old_stdout = sys.stdout
      sys.stdout = mystdout = StringIO()
      acc = mx.gluon.metric.Accuracy()
      log_interval = 5
      logging = LoggingHandler(metrics=[acc], log_interval=log_interval)
      est = estimator.Estimator(
          net=net, loss=ce_loss, train_metrics=acc
      )
      est.fit(
          train_data=dataloader,
          epochs=num_epochs,
          event_handlers=[logging],
      )
      sys.stdout = old_stdout
      log_info_list = mystdout.getvalue().splitlines()
      info_len = 0
      for info in log_info_list:
          match = re.match(
              r"(\[Epoch \d+\]\[Batch \d+\]\[Samples \d+\] time\/interval: \d+.\d+s"
              + r" training accuracy: \d+.\d+)",
              info,
          )
          if match:
              info_len += 1
  
      assert info_len == int(data_size / batch_size / log_interval) + 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 9 for calling a global function with example usage: test_logging_interval() without return types