def METHOD_NAME():
    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)
    # 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 = 448, 100  # "resnet18": {"orig_dims": 448, "reduced_dims": 100, "emb_scale": 4},
    class_name = args.category
    assert class_name in mvtec.CLASS_NAMES
    print("Testing model for {} with sigle picture".format(class_name))
    # build datasets
    MVTecDataset = mvtec.MVTecDataset(is_predict=True)
    transform_x = MVTecDataset.get_transform_x()
    x = Image.open(args.img_path).convert('RGB')
    x = transform_x(x).unsqueeze(0)
    idx = paddle.to_tensor(sample(range(0, t_d), d))
    test_outputs = OrderedDict([('layer1', []), ('layer2', []), ('layer3', [])])
    test_imgs = []
    test_imgs.extend(x.cpu().detach().numpy())
    # model prediction
    with paddle.no_grad():
        outputs = model(x)
    # get intermediate layer outputs
    for k, v in zip(test_outputs.keys(), outputs):
        test_outputs[k].append(v.cpu().detach())
    for k, v in test_outputs.items():
        test_outputs[k] = paddle.concat(v, 0)
    # Embedding concat
    embedding_vectors = test_outputs['layer1']
    for layer_name in ['layer2', 'layer3']:
        layer_embedding = test_outputs[layer_name]
        layer_embedding = F.interpolate(
            layer_embedding, size=embedding_vectors.shape[-2:], mode="nearest")
        embedding_vectors = paddle.concat((embedding_vectors, layer_embedding),
                                          1)
    # randomly select d dimension
    embedding_vectors = paddle.index_select(embedding_vectors, idx, 1)
    # calculate distance matrix
    B, C, H, W = embedding_vectors.shape
    embedding = embedding_vectors.reshape((B, C, H * W))
    # calculate mahalanobis distances
    mean, covariance = paddle.to_tensor(model.distribution[
        0]), paddle.to_tensor(model.distribution[1])
    inv_covariance = paddle.linalg.inv(covariance.transpose((2, 0, 1)))
    delta = (embedding - mean).transpose((2, 0, 1))
    distances = (paddle.matmul(delta, inv_covariance) * delta).sum(2).transpose(
        (1, 0))
    distances = distances.reshape((B, H, W))
    distances = paddle.sqrt(distances)
    # upsample
    score_map = F.interpolate(
        distances.unsqueeze(1),
        size=x.shape[2:],
        mode='bilinear',
        align_corners=False).squeeze(1).numpy()
    # apply gaussian smoothing on the score map
    for i in range(score_map.shape[0]):
        score_map[i] = gaussian_filter(score_map[i], sigma=4)
    # Normalization
    max_score = score_map.max()
    min_score = score_map.min()
    scores = (score_map - min_score) / (max_score - min_score)
    if args.save_pic:
        save_name = os.path.join(args.save_path, args.backbone, args.category)
        dir_name = os.path.dirname(save_name)
        if dir_name and not os.path.exists(dir_name):
            os.makedirs(dir_name)
        plot_fig(test_imgs, scores, args.threshold, save_name, class_name)
    print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + '\t' +
          "Predict :  Picture {}".format(args.img_path) + " done!")