code: def evaluate(args):
      (
          store,
          num_workers,
          rank,
          local_rank,
          is_master_node,
          ctx_l,
      ) = init_comm(args.comm_backend, args.gpus)
      # setup_logging(args, local_rank)
      task = get_task(args.task_name, args.train_dir, args.eval_dir)
      level = logging.INFO
      detail_dir = os.path.join(args.output_dir, args.task_name)
      if not os.path.exists(detail_dir):
          os.mkdir(detail_dir)
      logging_config(
          detail_dir,
          name="train_{}_{}_".format(args.task_name, args.model_name)
          + str(rank),  # avoid race
          level=level,
          console=(local_rank == 0),
      )
      if rank != 0:
          logging.info("Skipping node {}".format(rank))
          return
      ctx_l = parse_ctx(args.gpus)
      logging.info(
          "Srarting inference without horovod on the first node on device {}".format(
              str(ctx_l)
          )
      )
  
      cfg, tokenizer, classify_net, use_segmentation = get_network(
          args.model_name,
          ctx_l,
          args.param_checkpoint,
          args.backbone_path,
          task,
      )
      candidate_ckpt = []
      detail_dir = os.path.join(args.output_dir, args.task_name)
      for name in os.listdir(detail_dir):
          if (
              name.endswith(".params")
              and args.task_name in name
              and args.model_name in name
          ):
              candidate_ckpt.append(os.path.join(detail_dir, name))
      best_ckpt = {}
      metrics = task.metric
  
      def evaluate_by_ckpt(ckpt_name, best_ckpt):
          classify_net.load_parameters(
              ckpt_name, ctx=ctx_l, cast_dtype=True
          )
          logging.info("Prepare dev data")
  
          dev_data, label = get_task_data(
              args, task, tokenizer, segment="eval"
          )
          dev_batchify = bf.Group(
              bf.Group(bf.Pad(), bf.Pad(), bf.Stack()), bf.Stack()
          )
          dataloader = DataLoader(
              dev_data,
              batch_size=args.batch_size,
              batchify_fn=dev_batchify,
              shuffle=False,
          )
  
          for sample_l in grouper(dataloader, len(ctx_l)):
              for sample, ctx in zip(sample_l, ctx_l):
                  if sample is None:
                      continue
                  (token_ids, token_types, valid_length), label = sample
                  token_ids = mx.np.array(token_ids, ctx=ctx)
                  token_types = mx.np.array(token_types, ctx=ctx)
                  valid_length = mx.np.array(valid_length, ctx=ctx)
                  scores = classify_net(
                      token_ids, token_types, valid_length
                  )
  
                  if task.task_name == "sts":
                      label = label.reshape((-1, 1))
                  for metric in metrics:
                      metric.update([label], [scores])
                  # pred.append(scores)
  
          for metric in metrics:
              metric_name, result = metric.get()
              logging.info(
                  "checkpoint {} get result: {}:{}".format(
                      ckpt_name, metric_name, result
                  )
              )
              if best_ckpt.get(metric_name, [0, ""])[0] < result:
                  best_ckpt[metric_name] = [result, ckpt_name]
          for metric in metrics:
              metric.reset()
  
      for ckpt_name in candidate_ckpt:
          evaluate_by_ckpt(ckpt_name, best_ckpt)
      for metric_name in best_ckpt:
          logging.info(
              "best result on metric {}: is {}, and on checkpoint {}".format(
                  metric_name,
                  best_ckpt[metric_name][0],
                  best_ckpt[metric_name][1],
              )
          )
  
imports: import gluonnlp
  from tensorboardX import SummaryWriter
  import numpy
  import mxnet
  import json
  import random
  import pandas
  import os
  import logging
  import time
  import argparse
  import copy
  from mxnet.gluon.metric import Accuracy, F1, MCC, PearsonCorrelation, CompositeEvalMetric
  from classification_utils import get_task
  import matplotlib.pyplot
  from tqdm import tqdm
  from mxnet import gluon
  from gluonnlp.data.sampler import SplitSampler
  from mxnet.gluon import nn
  from gluonnlp.models import get_backbone
  from gluonnlp.utils.parameter import clip_grad_global_norm, count_parameters, deduplicate_param_dict
  from gluonnlp.utils.preprocessing import get_trimmed_lengths
  from gluonnlp.utils.misc import get_mxnet_visible_ctx, grouper, repeat, logging_config
  from mxnet.gluon.data import batchify
  from mxnet.gluon.data import DataLoader
  from mxnet.lr_scheduler import PolyScheduler
  from gluonnlp.utils import set_seed
  from gluonnlp.utils.misc import init_comm, parse_ctx
  from classification import TextPredictionNet
label_desc: Use image node_id 7 for calling a global function with example usage: evaluate(args) without return types