code: def model_inference(
      exe,
      gw,
      gf,
      program,
      pred,
      inputs,
      args,
      step_idx,
      min_va_val,
      min_val,
  ):
      """inference model"""
      x_val, x_test, x_stats = (
          inputs.get_data("val"),
          inputs.get_data("test"),
          inputs.get_stats(),
      )
  
      if args.n_his + args.n_pred > x_val.shape[1]:
          raise ValueError(
              f'ERROR: the value of n_pred "{args.n_pred}" exceeds the length limit.'
          )
  
      # y_val shape: [n_pred, len(x_val), n_route, C_0)
      y_val, len_val = multi_pred(
          exe,
          gw,
          gf,
          program,
          pred,
          x_val,
          args.batch_size,
          args.n_his,
          args.n_pred,
          step_idx,
      )
  
      evl_val = evaluation(
          x_val[0:len_val, step_idx + args.n_his, :, :],
          y_val[step_idx],
          x_stats,
      )
  
      # chks: indicator that reflects the relationship of values between evl_val and min_va_val.
      chks = evl_val < min_va_val
      # update the metric on test set, if model's performance got improved on the validation.
      if sum(chks):
          min_va_val[chks] = evl_val[chks]
          y_pred, len_pred = multi_pred(
              exe,
              gw,
              gf,
              program,
              pred,
              x_test,
              args.batch_size,
              args.n_his,
              args.n_pred,
              step_idx,
          )
  
          evl_pred = evaluation(
              x_test[0:len_pred, step_idx + args.n_his, :, :],
              y_pred[step_idx],
              x_stats,
          )
          min_val = evl_pred
  
      return min_va_val, min_val
  
file_path: PGL/legacy/examples/stgcn/models/tester.py
imports: import os
  import sys
  import time
  import argparse
  import numpy
  import pandas
  import paddle.fluid
  import paddle.fluid.layers
  import pgl
  from pgl.utils.logger import log
  from data_loader.data_utils import gen_batch
  from utils.math_utils import evaluation
label_desc: Use image node_id 2 for calling a global function with example usage: model_inference(exe, gw, gf, program, pred, inputs, args, step_idx, min_va_val, min_val) and returns: min_va_val,  min_val