class_docstr: PL Lightning Module for Reverse Distillation Algorithm.
  
  Args:
      input_size (tuple[int, int]): Size of model input
      backbone (str): Backbone of CNN network
      layers (list[str]): Layers to extract features from the backbone CNN
      pre_trained (bool, optional): Boolean to check whether to use a pre_trained backbone.
class_docstr_tok: ["PL","Lightning","Module","for","Reverse","Distillation","Algorithm",".","Args",":","input_size","(","tuple","[","int",",","int","]",")",":","Size","of","model","input","backbone","(","str",")",":","Backbone","of","CNN","network","layers","(","list","[","str","]",")",":","Layers","to","extract","features","from","the","backbone","CNN","pre_trained","(","bool",",","optional",")",":","Boolean","to","check","whether","to","use","a","pre_trained","backbone","."]
docstr: Training Step of Reverse Distillation Model.
  
  Features are extracted from three layers of the Encoder model. These are passed to the bottleneck layer
  that are passed to the decoder network. The loss is then calculated based on the cosine similarity between the
  encoder and decoder features.
  
  Args:
    batch (batch: dict[str, str | Tensor]): Input batch
  
  Returns:
    Feature Map
docstr_tok: ["Training","Step","of","Reverse","Distillation","Model",".","Features","are","extracted","from","three","layers","of","the","Encoder","model",".","These","are","passed","to","the","bottleneck","layer","that","are","passed","to","the","decoder","network",".","The","loss","is","then","calculated","based","on","the","cosine","similarity","between","the","encoder","and","decoder","features",".","Args",":","batch","(","batch",":","dict","[","str",",","str","|","Tensor","]",")",":","Input","batch","Returns",":","Feature","Map"]
code: def training_step(
      self, batch: dict[str, str | Tensor], *args, **kwargs
  ) -> STEP_OUTPUT:
      """Training Step of Reverse Distillation Model.
  
      Features are extracted from three layers of the Encoder model. These are passed to the bottleneck layer
      that are passed to the decoder network. The loss is then calculated based on the cosine similarity between the
      encoder and decoder features.
  
      Args:
        batch (batch: dict[str, str | Tensor]): Input batch
  
      Returns:
        Feature Map
      """
      del args, kwargs  # These variables are not used.
  
      loss = self.loss(*self.model(batch["image"]))
      self.log(
          "train_loss",
          loss.item(),
          on_epoch=True,
          prog_bar=True,
          logger=True,
      )
      return {"loss": loss}
  
file_path: anomalib/src/anomalib/models/reverse_distillation/lightning_model.py
imports: from __future__ import annotations
  from omegaconf import DictConfig, ListConfig
  from pytorch_lightning.callbacks import EarlyStopping
  from pytorch_lightning.utilities.types import STEP_OUTPUT
  from torch import Tensor, optim
  from anomalib.models.components import AnomalyModule
  from .anomaly_map import AnomalyMapGenerationMode
  from .loss import ReverseDistillationLoss
  from .torch_model import ReverseDistillationModel
label_desc: Use image node_id 3 for calling the ReverseDistillation obj's underlying member method code with example usage: obj.training_step(batch) and returns: dict