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
      csv_columns = ["category", "Image_AUROC", "Pixel_AUROC"]
      csv_name = os.path.join(
          args.save_path + args.backbone,
          "{}_seed{}.csv".format(args.category, args.seed),
      )
      # build model
      model = ResNet_PaDiM(arch=args.backbone, pretrained=False)
      state = paddle.load(args.model_path)
      model.model.set_dict(state["params"])
      model.distribution = state["distribution"]
      model.eval()
  
      t_d, d = (
          fins[args.backbone],
          100,
      )  # "resnet18": {"orig_dims": 448, "reduced_dims": 100, "emb_scale": 4}
      idx = paddle.to_tensor(sample(range(0, t_d), d))
      class_name = args.category
      print("Eval model for {}".format(class_name))
  
      # 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.batch_size,
          num_workers=args.num_workers,
      )
      result.append(
          [
              class_name,
              *val(args, model, test_dataloader, class_name, idx),
          ]
      )
      result = pd.DataFrame(result, columns=csv_columns).set_index(
          "category"
      )
      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
  from random import sample
  from collections import OrderedDict
  import numpy
  import pandas
  import matplotlib
  import matplotlib.pyplot
  from tqdm import tqdm
  from sklearn.metrics import roc_auc_score
  from sklearn.metrics import roc_curve
  from sklearn.metrics import precision_recall_curve
  from scipy.spatial.distance import mahalanobis
  from scipy.ndimage import gaussian_filter
  from skimage import morphology
  from skimage.segmentation import mark_boundaries
  import paddle
  import paddle.nn.functional
  from paddle.io import DataLoader
  import qinspector.uad.datasets.mvtec
  from qinspector.uad.models.padim import ResNet_PaDiM
  from qinspector.cvlib.uad_configs import *
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types