def transform(self, embedding: torch.Tensor) -> torch.Tensor:
        """Project the data using the random projection matrix.

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

        Returns:
            torch.Tensor: Projected tensor of shape
                ``(n_samples, n_components)``.

        Raises:
            NotFittedError: If transform is called before fitting.

        Example:
            >>> projector = SparseRandomProjection()
            >>> data = torch.randn(100, 50)
            >>> projector.fit(data)
            >>> projected = projector.transform(data)
            >>> print(projected.shape)
        """
        if self.sparse_random_matrix is None:
            msg = "`fit()` has not been called on SparseRandomProjection yet."
            raise NotFittedError(msg)

        return embedding @ self.sparse_random_matrix.T.float()
Project the data using the random projection matrix.

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

        Returns:
            torch.Tensor: Projected tensor of shape
                ``(n_samples, n_components)``.

        Raises:
            NotFittedError: If transform is called before fitting.

        Example:
            >>> projector = SparseRandomProjection()
            >>> data = torch.randn(100, 50)
            >>> projector.fit(data)
            >>> projected = projector.transform(data)
            >>> print(projected.shape)
        
src/anomalib/models/components/dimensionality_reduction/random_projection.py