def forward(self, batch: torch.Tensor) -> InferenceBatch:
        """Generate anomaly predictions for input images.

        The method:
        1. Extracts and reconstructs features using the tied autoencoder
        2. Computes reconstruction error as anomaly scores
        3. Generates pixel-wise anomaly maps
        4. Upsamples anomaly maps to input image size

        Args:
            batch (torch.Tensor): Input image batch of shape
                ``(N, C, H, W)``.

        Returns:
            InferenceBatch: Batch containing:
                - Anomaly scores of shape ``(N,)``
                - Anomaly maps of shape ``(N, 1, H, W)``
        """
        features_in, features_out, feature_shapes = self.get_features(batch)
        fre = torch.square(features_in - features_out).reshape(feature_shapes)
        anomaly_map = torch.sum(fre, 1)  # NxCxHxW --> NxHxW
        score = torch.sum(anomaly_map, (1, 2))  # NxHxW --> N
        anomaly_map = torch.unsqueeze(anomaly_map, 1)
        anomaly_map = F.interpolate(anomaly_map, size=batch.shape[-2:], mode="bilinear", align_corners=False)
        return InferenceBatch(pred_score=score, anomaly_map=anomaly_map)
Generate anomaly predictions for input images.

        The method:
        1. Extracts and reconstructs features using the tied autoencoder
        2. Computes reconstruction error as anomaly scores
        3. Generates pixel-wise anomaly maps
        4. Upsamples anomaly maps to input image size

        Args:
            batch (torch.Tensor): Input image batch of shape
                ``(N, C, H, W)``.

        Returns:
            InferenceBatch: Batch containing:
                - Anomaly scores of shape ``(N,)``
                - Anomaly maps of shape ``(N, 1, H, W)``
        
src/anomalib/models/image/fre/torch_model.py