class_docstr: Abstract class for the inference.
  
  This is used by both Torch and OpenVINO inference.
class_docstr_tok: ["Abstract","class","for","the","inference",".","This","is","used","by","both","Torch","and","OpenVINO","inference","."]
docstr: Applies normalization and resizes the image.
  
  Args:
      pred_scores (Tensor | np.float32): Predicted anomaly score
      metadata (dict | DictConfig): Meta data. Post-processing step sometimes requires
          additional meta data such as image shape. This variable comprises such info.
      anomaly_maps (Tensor | np.ndarray | None): Predicted raw anomaly map.
  
  Returns:
      tuple[np.ndarray | Tensor | None, float]: Post processed predictions that are ready to be
          visualized and predicted scores.
docstr_tok: ["Applies","normalization","and","resizes","the","image",".","Args",":","pred_scores","(","Tensor","|","np.float32",")",":","Predicted","anomaly","score","metadata","(","dict","|","DictConfig",")",":","Meta","data",".","Post-processing","step","sometimes","requires","additional","meta","data","such","as","image","shape",".","This","variable","comprises","such","info",".","anomaly_maps","(","Tensor","|","np.ndarray","|","None",")",":","Predicted","raw","anomaly","map",".","Returns",":","tuple","[","np.ndarray","|","Tensor","|","None",",","float","]",":","Post","processed","predictions","that","are","ready","to","be","visualized","and","predicted","scores","."]
code: def _normalize(
      pred_scores: Tensor | np.float32,
      metadata: dict | DictConfig,
      anomaly_maps: Tensor | np.ndarray | None = None,
  ) -> tuple[np.ndarray | Tensor | None, float]:
      """Applies normalization and resizes the image.
  
      Args:
          pred_scores (Tensor | np.float32): Predicted anomaly score
          metadata (dict | DictConfig): Meta data. Post-processing step sometimes requires
              additional meta data such as image shape. This variable comprises such info.
          anomaly_maps (Tensor | np.ndarray | None): Predicted raw anomaly map.
  
      Returns:
          tuple[np.ndarray | Tensor | None, float]: Post processed predictions that are ready to be
              visualized and predicted scores.
      """
  
      # min max normalization
      if "min" in metadata and "max" in metadata:
          if anomaly_maps is not None:
              anomaly_maps = normalize_min_max(
                  anomaly_maps,
                  metadata["pixel_threshold"],
                  metadata["min"],
                  metadata["max"],
              )
          pred_scores = normalize_min_max(
              pred_scores,
              metadata["image_threshold"],
              metadata["min"],
              metadata["max"],
          )
  
      # standardize pixel scores
      if (
          "pixel_mean" in metadata.keys()
          and "pixel_std" in metadata.keys()
      ):
          if anomaly_maps is not None:
              anomaly_maps = standardize(
                  anomaly_maps,
                  metadata["pixel_mean"],
                  metadata["pixel_std"],
                  center_at=metadata["image_mean"],
              )
              anomaly_maps = normalize_cdf(
                  anomaly_maps, metadata["pixel_threshold"]
              )
  
      # standardize image scores
      if (
          "image_mean" in metadata.keys()
          and "image_std" in metadata.keys()
      ):
          pred_scores = standardize(
              pred_scores, metadata["image_mean"], metadata["image_std"]
          )
          pred_scores = normalize_cdf(
              pred_scores, metadata["image_threshold"]
          )
  
      return anomaly_maps, float(pred_scores)
  
imports: from __future__ import annotations
  from abc import ABC, abstractmethod
  from pathlib import Path
  from typing import Any, cast
  import cv2
  import numpy
  from omegaconf import DictConfig, OmegaConf
  from skimage.morphology import dilation
  from skimage.segmentation import find_boundaries
  from torch import Tensor
  from anomalib.data.utils import read_image
  from anomalib.post_processing import ImageResult, compute_mask
  from anomalib.post_processing.normalization.cdf import normalize
  from anomalib.post_processing.normalization.cdf import standardize
  from anomalib.post_processing.normalization.min_max import normalize
label_desc: Use image node_id 8 for calling the Inferencer obj's underlying member method code with example usage: obj._normalize(pred_scores, metadata, anomaly_maps) and returns: anomaly_maps,  float