class_docstr: AnomalyModule to train, validate, predict and test images.
  
  Acts as a base class for all the Anomaly Modules in the library.
class_docstr_tok: ["AnomalyModule","to","train",",","validate",",","predict","and","test","images",".","Acts","as","a","base","class","for","all","the","Anomaly","Modules","in","the","library","."]
docstr: Compute labels based on model predictions.
docstr_tok: ["Compute","labels","based","on","model","predictions","."]
code: def _post_process(outputs: STEP_OUTPUT) -> None:
      """Compute labels based on model predictions."""
      if isinstance(outputs, dict):
          if "pred_scores" not in outputs and "anomaly_maps" in outputs:
              # infer image scores from anomaly maps
              outputs["pred_scores"] = (
                  outputs["anomaly_maps"]
                  .reshape(outputs["anomaly_maps"].shape[0], -1)
                  .max(dim=1)
                  .values
              )
          elif "pred_scores" not in outputs and "box_scores" in outputs:
              # infer image score from bbox confidence scores
              outputs["pred_scores"] = torch.zeros_like(
                  outputs["label"]
              ).float()
              for idx, (boxes, scores) in enumerate(
                  zip(outputs["pred_boxes"], outputs["box_scores"])
              ):
                  if boxes.numel():
                      outputs["pred_scores"][idx] = scores.max().item()
  
          if "pred_boxes" in outputs and "anomaly_maps" not in outputs:
              # create anomaly maps from bbox predictions for thresholding and evaluation
              image_size: tuple[int, int] = outputs["image"].shape[-2:]
              true_boxes: list[Tensor] = outputs["boxes"]
              pred_boxes: Tensor = outputs["pred_boxes"]
              box_scores: Tensor = outputs["box_scores"]
  
              outputs["anomaly_maps"] = boxes_to_anomaly_maps(
                  pred_boxes, box_scores, image_size
              )
              outputs["mask"] = boxes_to_masks(true_boxes, image_size)
  
imports: from __future__ import annotations
  import importlib
  import logging
  from abc import ABC
  from typing import Any, OrderedDict
  from warnings import warn
  import pytorch_lightning
  import torch
  from pytorch_lightning.callbacks import Callback
  from pytorch_lightning.utilities.types import EPOCH_OUTPUT, STEP_OUTPUT
  from torch import Tensor, nn
  from torchmetrics import Metric
  from anomalib.data.utils import boxes_to_anomaly_maps, boxes_to_masks, masks_to_boxes
  from anomalib.post_processing import ThresholdMethod
  from anomalib.utils.metrics import AnomalibMetricCollection, AnomalyScoreDistribution, AnomalyScoreThreshold, MinMax
label_desc: Use image node_id 12 for calling the AnomalyModule obj's underlying member method code with example usage: obj._post_process(outputs) without return types