def backward(loss: torch.Tensor, *args, **kwargs) -> None:
        """Perform backward pass.

        Args:
            loss (torch.Tensor): Computed loss value.
            *args: Additional positional arguments (unused).
            **kwargs: Additional keyword arguments (unused).

        Note:
            Uses ``retain_graph=True`` due to computational graph requirements.
            See CVS-122673 for more details.
        """
        del args, kwargs  # These variables are not used.

        # TODO(samet-akcay): Investigate why retain_graph is needed.
        # CVS-122673
        loss.backward(retain_graph=True)
Perform backward pass.

        Args:
            loss (torch.Tensor): Computed loss value.
            *args: Additional positional arguments (unused).
            **kwargs: Additional keyword arguments (unused).

        Note:
            Uses ``retain_graph=True`` due to computational graph requirements.
            See CVS-122673 for more details.
        
src/anomalib/models/image/cfa/lightning_model.py