def compute_layer_loss(self, teacher_feats: torch.Tensor, student_feats: torch.Tensor) -> torch.Tensor:
        """Compute loss between teacher and student features for a single layer.

        This implements the loss computation based on Equation (1) in Section 3.2
        of the paper. The loss is computed as:
        1. L2 normalize teacher and student features
        2. Compute MSE loss between normalized features
        3. Scale loss by spatial dimensions (height * width)

        Args:
            teacher_feats (torch.Tensor): Features from teacher network with shape
                ``(B, C, H, W)``
            student_feats (torch.Tensor): Features from student network with shape
                ``(B, C, H, W)``

        Returns:
            torch.Tensor: Scalar loss value for the layer
        """
        height, width = teacher_feats.shape[2:]

        norm_teacher_features = F.normalize(teacher_feats)
        norm_student_features = F.normalize(student_feats)
        return (0.5 / (width * height)) * self.mse_loss(norm_teacher_features, norm_student_features)
Compute loss between teacher and student features for a single layer.

        This implements the loss computation based on Equation (1) in Section 3.2
        of the paper. The loss is computed as:
        1. L2 normalize teacher and student features
        2. Compute MSE loss between normalized features
        3. Scale loss by spatial dimensions (height * width)

        Args:
            teacher_feats (torch.Tensor): Features from teacher network with shape
                ``(B, C, H, W)``
            student_feats (torch.Tensor): Features from student network with shape
                ``(B, C, H, W)``

        Returns:
            torch.Tensor: Scalar loss value for the layer
        
src/anomalib/models/image/stfpm/loss.py