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: Step function called during :meth:`~pytorch_lightning.trainer.trainer.Trainer.predict`.
  
  By default, it calls :meth:`~pytorch_lightning.core.lightning.LightningModule.forward`.
  Override to add any processing logic.
  
  Args:
      batch (Any): Current batch
      batch_idx (int): Index of current batch
      dataloader_idx (int): Index of the current dataloader
  
  Return:
      Predicted output
docstr_tok: ["Step","function","called","during",":","meth",":","`","~pytorch_lightning.trainer.trainer.Trainer.predict","`",".","By","default",",","it","calls",":","meth",":","`","~pytorch_lightning.core.lightning.LightningModule.forward","`",".","Override","to","add","any","processing","logic",".","Args",":","batch","(","Any",")",":","Current","batch","batch_idx","(","int",")",":","Index","of","current","batch","dataloader_idx","(","int",")",":","Index","of","the","current","dataloader","Return",":","Predicted","output"]
code: def predict_step(
      self, batch: Any, batch_idx: int, dataloader_idx: int = 0
  ) -> Any:
      """Step function called during :meth:`~pytorch_lightning.trainer.trainer.Trainer.predict`.
  
      By default, it calls :meth:`~pytorch_lightning.core.lightning.LightningModule.forward`.
      Override to add any processing logic.
  
      Args:
          batch (Any): Current batch
          batch_idx (int): Index of current batch
          dataloader_idx (int): Index of the current dataloader
  
      Return:
          Predicted output
      """
      del batch_idx, dataloader_idx  # These variables are not used.
  
      outputs: Tensor | dict[str, Any] = self.validation_step(batch)
      self._post_process(outputs)
      if outputs is not None and isinstance(outputs, dict):
          outputs["pred_labels"] = (
              outputs["pred_scores"] >= self.image_threshold.value
          )
          if "anomaly_maps" in outputs.keys():
              outputs["pred_masks"] = (
                  outputs["anomaly_maps"] >= self.pixel_threshold.value
              )
              if "pred_boxes" not in outputs.keys():
                  (
                      outputs["pred_boxes"],
                      outputs["box_scores"],
                  ) = masks_to_boxes(
                      outputs["pred_masks"], outputs["anomaly_maps"]
                  )
                  outputs["box_labels"] = [
                      torch.ones(boxes.shape[0])
                      for boxes in outputs["pred_boxes"]
                  ]
          # apply thresholding to boxes
          if "box_scores" in outputs and "box_labels" not in outputs:
              # apply threshold to assign normal/anomalous label to boxes
              is_anomalous = [
                  scores > self.pixel_threshold.value
                  for scores in outputs["box_scores"]
              ]
              outputs["box_labels"] = [
                  labels.int() for labels in is_anomalous
              ]
      return outputs
  
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 4 for calling the AnomalyModule obj's underlying member method code with example usage: obj.predict_step(batch, batch_idx, dataloader_idx) and returns: outputs