code: def main():
      args = argsparser()
      config_parser = ConfigParser(args)
      args = config_parser.parser()
  
      random.seed(args.seed)
      np.random.seed(args.seed)
      paddle.seed(args.seed)
      paddle.device.set_device(args.device)
  
      result = []
      assert args.category in mvtec.CLASS_NAMES + [
          "all",
          "textures",
          "objects",
      ]
      class_names = (
          mvtec.CLASS_NAMES
          if args.category == "all"
          else [args.category]
      )
      csv_columns = [
          "category",
          "Image_AUROC",
          "Pixel_AUROC",
          "PRO_score",
      ]
      csv_name = os.path.join(
          args.save_path + f"/{args.method}_{args.backbone}_{args.k}",
          "{}_seed{}.csv".format(args.category, args.seed),
      )
      for i, class_name in enumerate(class_names):
          print(
              "Eval model {}/{} for {}".format(
                  i + 1, len(class_names), class_name
              )
          )
  
          # build model
          model_path = (
              args.model_path
              or args.save_path
              + f"/{args.method}_{args.arch}_{args.k}"
              + "/{}.pdparams".format(class_name)
          )
          model = get_model(args.method)(
              arch=args.backbone,
              pretrained=False,
              k=args.k,
              method=args.method,
          )
          state = paddle.load(model_path)
          model.model.set_dict(state["params"])
          model.load(state["stats"])
          model.eval()
  
          # build datasets
          test_dataset = mvtec.MVTecDataset(
              args.data_path,
              class_name=class_name,
              is_train=False,
              resize=args.resize,
              cropsize=args.crop_size,
          )
          test_dataloader = DataLoader(
              test_dataset,
              batch_size=args.test_batch_size,
              num_workers=args.num_workers,
          )
          result.append(
              [
                  class_name,
                  *val(args, model, test_dataloader, class_name),
              ]
          )
          if args.category in ["all", "textures", "objects"]:
              pd.DataFrame(result, columns=csv_columns).set_index(
                  "category"
              ).to_csv(csv_name)
      result = pd.DataFrame(result, columns=csv_columns).set_index(
          "category"
      )
      if not args.eval_PRO:
          result = result.drop(columns="PRO_score")
      if args.category in ["all", "textures", "objects"]:
          result.loc["mean"] = result.mean(numeric_only=True)
      print(result)
      print("Evaluation result saved at{}:".format(csv_name))
      result.to_csv(csv_name)
  
imports: import os
  import sys
  import random
  import argparse
  import datetime
  import numpy
  import pandas
  import matplotlib.pyplot
  from tqdm import tqdm
  from sklearn.metrics import roc_curve, precision_recall_curve
  import paddle
  from paddle.io import DataLoader
  import qinspector.uad.datasets.mvtec
  from qinspector.uad.models.patchcore import get_model
  from qinspector.uad.utils.utils import *
  from qinspector.cvlib.uad_configs import ConfigParser
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types