def forward(self, input_tensor: torch.Tensor) -> torch.Tensor | InferenceBatch:
        """Forward-pass image-batch (N, C, H, W) into model to extract features.

        Args:
            input_tensor (torch.Tensor): Image batch with shape (N, C, H, W)

        Returns:
            torch.Tensor | InferenceBatch: If training, returns the embeddings.
                If inference, returns ``InferenceBatch`` containing prediction
                scores and anomaly maps.

        Example:
            >>> model = PadimModel()
            >>> x = torch.randn(32, 3, 224, 224)
            >>> features = model.extract_features(x)
            >>> features.keys()
            dict_keys(['layer1', 'layer2', 'layer3'])
            >>> [v.shape for v in features.values()]
            [torch.Size([32, 64, 56, 56]),
            torch.Size([32, 128, 28, 28]),
            torch.Size([32, 256, 14, 14])]
        """
        output_size = input_tensor.shape[-2:]
        if self.tiler:
            input_tensor = self.tiler.tile(input_tensor)

        with torch.no_grad():
            features = self.feature_extractor(input_tensor)
            embeddings = self.generate_embedding(features)

        if self.tiler:
            embeddings = self.tiler.untile(embeddings)

        if self.training:
            return embeddings

        anomaly_map = self.anomaly_map_generator(
            embedding=embeddings,
            mean=self.gaussian.mean,
            inv_covariance=self.gaussian.inv_covariance,
            image_size=output_size,
        )
        pred_score = torch.amax(anomaly_map, dim=(-2, -1))
        return InferenceBatch(pred_score=pred_score, anomaly_map=anomaly_map)
Forward-pass image-batch (N, C, H, W) into model to extract features.

        Args:
            input_tensor (torch.Tensor): Image batch with shape (N, C, H, W)

        Returns:
            torch.Tensor | InferenceBatch: If training, returns the embeddings.
                If inference, returns ``InferenceBatch`` containing prediction
                scores and anomaly maps.

        Example:
            >>> model = PadimModel()
            >>> x = torch.randn(32, 3, 224, 224)
            >>> features = model.extract_features(x)
            >>> features.keys()
            dict_keys(['layer1', 'layer2', 'layer3'])
            >>> [v.shape for v in features.values()]
            [torch.Size([32, 64, 56, 56]),
            torch.Size([32, 128, 28, 28]),
            torch.Size([32, 256, 14, 14])]
        
src/anomalib/models/image/padim/torch_model.py