def fit_transform(self, dataset: torch.Tensor) -> torch.Tensor:
        """Fit the model and transform the input dataset.

        Args:
            dataset (torch.Tensor): Input dataset of shape ``(n_samples,
                n_features)``.

        Returns:
            torch.Tensor: Transformed dataset of shape ``(n_samples,
                n_components)``.

        Example:
            >>> data = torch.randn(100, 10)
            >>> pca = PCA(n_components=3)
            >>> transformed = pca.fit_transform(data)
            >>> print(transformed.shape)
            torch.Size([100, 3])
        """
        mean = dataset.mean(dim=0)
        dataset -= mean
        num_components = int(self.n_components)
        self.num_components = torch.tensor([num_components], device=dataset.device)

        v_h = torch.linalg.svd(dataset)[-1]
        self.singular_vectors = v_h.transpose(-2, -1)[:, :num_components]
        self.mean = mean

        return torch.matmul(dataset, self.singular_vectors)
Fit the model and transform the input dataset.

        Args:
            dataset (torch.Tensor): Input dataset of shape ``(n_samples,
                n_features)``.

        Returns:
            torch.Tensor: Transformed dataset of shape ``(n_samples,
                n_components)``.

        Example:
            >>> data = torch.randn(100, 10)
            >>> pca = PCA(n_components=3)
            >>> transformed = pca.fit_transform(data)
            >>> print(transformed.shape)
            torch.Size([100, 3])
        
src/anomalib/models/components/dimensionality_reduction/pca.py