code: def test_metric_performance():
      """unittest entry for metric performance benchmarking"""
      # Each dictionary entry is (metric_name:(kwargs, DataGenClass))
      metrics = [
          ("acc", ({}, MetricDataGen)),
          ("top_k_acc", ({"top_k": 5}, MetricDataGen)),
          ("F1", ({}, F1MetricDataGen)),
          ("Perplexity", ({"ignore_label": -1}, MetricDataGen)),
          ("MAE", ({}, MetricDataGen)),
          ("MSE", ({}, MetricDataGen)),
          ("RMSE", ({}, MetricDataGen)),
          ("ce", ({}, MetricDataGen)),
          ("nll_loss", ({}, MetricDataGen)),
          ("pearsonr", ({}, PearsonMetricDataGen)),
      ]
  
      data_size = 1024 * 128
  
      batch_sizes = [16, 64, 256, 1024]
      output_dims = [128, 1024, 8192]
      ctxs = [mx.cpu(), mx.gpu()]
  
      print("\nmx.gluon.metric benchmarks", file=sys.stderr)
      print(
          f"{'Metric':15}{'Data-Ctx':10}{'Label-Ctx':12}{'Data Size':12}{'Batch Size':15}{'Output Dim':15}{'Elapsed Time'}",
          file=sys.stderr,
      )
      print(f"{'':-^90}", file=sys.stderr)
      for k, v in metrics:
          for c in output_dims:
              for n in batch_sizes:
                  for pred_ctx, label_ctx in itertools.product(
                      ctxs, ctxs
                  ):
                      run_metric(
                          k,
                          v[1],
                          (data_size * 128),
                          (n * c),
                          n,
                          c,
                          pred_ctx,
                          label_ctx,
                          **v[0],
                      )
                  print(f"{'':-^90}", file=sys.stderr)
  
file_path: mxnet/benchmark/python/metric/benchmark_metric.py
imports: from __future__ import print_function
  import itertools
  import mxnet
  import sys
  import time
label_desc: Use image node_id 2 for calling a global function with example usage: test_metric_performance() without return types