class_docstr: DRÆM: A discriminatively trained reconstruction embedding for surface anomaly detection.
  
  Args:
      anomaly_source_path (str | None): Path to folder that contains the anomaly source images. Random noise will
          be used if left empty.
class_docstr_tok: ["DR\u00c6M",":","A","discriminatively","trained","reconstruction","embedding","for","surface","anomaly","detection",".","Args",":","anomaly_source_path","(","str","|","None",")",":","Path","to","folder","that","contains","the","anomaly","source","images",".","Random","noise","will","be","used","if","left","empty","."]
docstr: Training Step of DRAEM.
  
  Feeds the original image and the simulated anomaly
  image through the network and computes the training loss.
  
  Args:
      batch (dict[str, str | Tensor]): Batch containing image filename, image, label and mask
  
  Returns:
      Loss dictionary
docstr_tok: ["Training","Step","of","DRAEM",".","Feeds","the","original","image","and","the","simulated","anomaly","image","through","the","network","and","computes","the","training","loss",".","Args",":","batch","(","dict","[","str",",","str","|","Tensor","]",")",":","Batch","containing","image","filename",",","image",",","label","and","mask","Returns",":","Loss","dictionary"]
code: def training_step(
      self, batch: dict[str, str | Tensor], *args, **kwargs
  ) -> STEP_OUTPUT:
      """Training Step of DRAEM.
  
      Feeds the original image and the simulated anomaly
      image through the network and computes the training loss.
  
      Args:
          batch (dict[str, str | Tensor]): Batch containing image filename, image, label and mask
  
      Returns:
          Loss dictionary
      """
      del args, kwargs  # These variables are not used.
  
      input_image = batch["image"]
      # Apply corruption to input image
      augmented_image, anomaly_mask = self.augmenter.augment_batch(
          input_image
      )
      # Generate model prediction
      reconstruction, prediction = self.model(augmented_image)
      # Compute loss
      loss = self.loss(
          input_image, reconstruction, anomaly_mask, prediction
      )
  
      if self.sspcab:
          loss += self.sspcab_lambda * self.sspcab_loss(
              self.sspcab_activations["input"],
              self.sspcab_activations["output"],
          )
  
      self.log(
          "train_loss",
          loss.item(),
          on_epoch=True,
          prog_bar=True,
          logger=True,
      )
      return {"loss": loss}
  
imports: from __future__ import annotations
  from typing import Callable
  import torch
  from omegaconf import DictConfig, ListConfig
  from pytorch_lightning.callbacks import EarlyStopping
  from pytorch_lightning.utilities.types import STEP_OUTPUT
  from torch import Tensor, nn
  from anomalib.data.utils import Augmenter
  from anomalib.models.components import AnomalyModule
  from anomalib.models.draem.loss import DraemLoss
  from anomalib.models.draem.torch_model import DraemModel
label_desc: Use image node_id 3 for calling the Draem obj's underlying member method code with example usage: obj.training_step(batch) and returns: dict