code: def eval_function(
      exe, compiled_test_program, test_feed_names, test_fetch_list
  ):
      """
      计算模型在验证集上的评估指标。
  
      Args:
          exe: 执行器。
          compiled_test_program: 编译后的测试程序。
          test_feed_names: 测试输入的名称。
          test_fetch_list: 测试需要获取的变量列表。
  
      Returns:
          miou: IoU 平均值。
      """
      batch_sampler = paddle.io.BatchSampler(
          eval_dataset, batch_size=1, shuffle=False, drop_last=False
      )
      loader = paddle.io.DataLoader(
          eval_dataset,
          batch_sampler=batch_sampler,
          num_workers=0,
          return_list=True,
      )
  
      total_iters = len(loader)
      intersect_area_all = 0
      pred_area_all = 0
      label_area_all = 0
  
      print(
          "Start evaluating (total_samples: {}, total_iters: {})...".format(
              len(eval_dataset), total_iters
          )
      )
  
      for iters, data in enumerate(loader):
          image, label = data["img"], data["label"]
          label = np.array(label).astype("int64")
          image = np.array(image)
  
          logits = exe.run(
              compiled_test_program,
              feed={test_feed_names[0]: image},
              fetch_list=test_fetch_list,
              return_numpy=True,
          )
  
          paddle.disable_static()
          logit = logits[
              0
          ]  # logit shape is 3, except  data['trans_info'] needs to be empty
          logit = reverse_transform(
              paddle.to_tensor(logit),
              data["trans_info"],
              mode="bilinear",
          )
          pred = paddle.to_tensor(logit)
          if (
              len(pred.shape) == 4
          ):  # for humanseg model whose prediction is distribution but not class id
              pred = paddle.argmax(
                  pred, axis=1, keepdim=True, dtype="int32"
              )
  
          (
              intersect_area,
              pred_area,
              label_area,
          ) = metrics.calculate_area(
              pred,
              paddle.to_tensor(label),
              eval_dataset.num_classes,
              ignore_index=eval_dataset.ignore_index,
          )
          intersect_area_all = intersect_area_all + intersect_area
          pred_area_all = pred_area_all + pred_area
          label_area_all = label_area_all + label_area
          if iters % 100 == 0:
              print("Eval iter:", iters)
  
      _, miou = metrics.mean_iou(
          intersect_area_all, pred_area_all, label_area_all
      )
      _, acc = metrics.accuracy(intersect_area_all, pred_area_all)
      kappa = metrics.kappa(
          intersect_area_all, pred_area_all, label_area_all
      )
      _, mdice = metrics.dice(
          intersect_area_all, pred_area_all, label_area_all
      )
  
      infor = "[EVAL] #Images: {} mIoU: {:.4f} Acc: {:.4f} Kappa: {:.4f} Dice: {:.4f}".format(
          len(eval_dataset), miou, acc, kappa, mdice
      )
      print(infor)
  
      paddle.enable_static()
      return miou
  
file_path: PaddleSeg/deploy/slim/act/run_seg.py
imports: import os
  import argparse
  import random
  import paddle
  import numpy
  from paddleseg.cvlibs import Config
  from paddleseg.cvlibs import SegBuilder
  from paddleseg.utils import worker_init_fn, metrics
  from paddleseg.core.infer import reverse_transform
  from paddleslim.auto_compression import AutoCompression
  from paddleslim.common import load_config
  from paddleslim.common.dataloader import get_feed_vars
label_desc: Use image node_id 2 for calling a global function with example usage: eval_function(exe, compiled_test_program, test_feed_names, test_fetch_list) and returns: miou