code: def test_trainer():
      """test with no trainer and invalid trainer"""
      net = _get_test_network()
      train_data, _ = _get_test_data()
      num_epochs = 1
      device = mx.cpu()
  
      loss = gluon.loss.L2Loss()
      acc = mx.gluon.metric.Accuracy()
      net.initialize(device=device)
      # input no trainer
      with warnings.catch_warnings(record=True) as w:
          est = Estimator(
              net=net, loss=loss, train_metrics=acc, device=device
          )
          assert "No trainer specified" in str(w[-1].message)
      est.fit(train_data=train_data, epochs=num_epochs)
  
      # input invalid trainer
      trainer = "sgd"
      with pytest.raises(ValueError):
          est = Estimator(
              net=net,
              loss=loss,
              train_metrics=acc,
              trainer=trainer,
              device=device,
          )
  
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 6 for calling a global function with example usage: test_trainer() without return types