def fit(self, dataset: torch.Tensor) -> None:
        """Fit a Gaussian model to dataset X.

        Covariance matrix is not calculated directly using ``C = X.X^T``.
        Instead, it is represented using SVD of X: ``X = U.S.V^T``.
        Hence, ``C = U.S^2.U^T``. This simplifies the calculation of the
        log-likelihood without requiring full matrix inversion.

        Args:
            dataset (torch.Tensor): Input dataset to fit the model with shape
                ``(n_features, n_samples)``.
        """
        num_samples = dataset.shape[1]
        self.mean_vec = torch.mean(dataset, dim=1, device=dataset.device)
        data_centered = (dataset - self.mean_vec.reshape(-1, 1)) / math.sqrt(num_samples)
        self.u_mat, self.sigma_mat, _ = torch.linalg.svd(data_centered, full_matrices=False)
Fit a Gaussian model to dataset X.

        Covariance matrix is not calculated directly using ``C = X.X^T``.
        Instead, it is represented using SVD of X: ``X = U.S.V^T``.
        Hence, ``C = U.S^2.U^T``. This simplifies the calculation of the
        log-likelihood without requiring full matrix inversion.

        Args:
            dataset (torch.Tensor): Input dataset to fit the model with shape
                ``(n_features, n_samples)``.
        
src/anomalib/models/image/dfm/torch_model.py