def get_features(self, batch: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
        """Extract and reconstruct features from the pretrained network.

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

        Returns:
            tuple[torch.Tensor, torch.Tensor, torch.Tensor]: Tuple containing:
                - Original features of shape ``(N, D)``
                - Reconstructed features of shape ``(N, D)``
                - Original feature tensor shape ``(N, C, H, W)``
                where ``D`` is the flattened feature dimension.
        """
        self.feature_extractor.eval()
        features_in = self.feature_extractor(batch)[self.layer]
        batch_size = len(features_in)
        if self.pooling_kernel_size > 1:
            features_in = F.avg_pool2d(input=features_in, kernel_size=self.pooling_kernel_size)
        feature_shapes = features_in.shape
        features_in = features_in.view(batch_size, -1).detach()
        features_out = self.fre_model(features_in)
        return features_in, features_out, feature_shapes
Extract and reconstruct features from the pretrained network.

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

        Returns:
            tuple[torch.Tensor, torch.Tensor, torch.Tensor]: Tuple containing:
                - Original features of shape ``(N, D)``
                - Reconstructed features of shape ``(N, D)``
                - Original feature tensor shape ``(N, C, H, W)``
                where ``D`` is the flattened feature dimension.
        
src/anomalib/models/image/fre/torch_model.py