def predict(self, inputs: torch.Tensor) -> torch.Tensor:
        """Predict cluster labels for input data.

        Args:
            inputs (torch.Tensor): Input data to assign to clusters.
                Shape: ``(n_samples, n_features)``.

        Returns:
            torch.Tensor: Predicted cluster labels.
                Shape: ``(n_samples,)``.

        Raises:
            AttributeError: If called before fitting the model.

        Example:
            >>> kmeans = KMeans(n_clusters=2)
            >>> # First fit the model
            >>> train_data = torch.tensor([[1.0, 2.0], [4.0, 5.0]])
            >>> kmeans.fit(train_data)
            >>> # Then predict on new data
            >>> new_data = torch.tensor([[1.1, 2.1], [3.9, 4.8]])
            >>> predictions = kmeans.predict(new_data)
        """
        distances = torch.cdist(inputs, self.cluster_centers_)
        return torch.argmin(distances, dim=1)
Predict cluster labels for input data.

        Args:
            inputs (torch.Tensor): Input data to assign to clusters.
                Shape: ``(n_samples, n_features)``.

        Returns:
            torch.Tensor: Predicted cluster labels.
                Shape: ``(n_samples,)``.

        Raises:
            AttributeError: If called before fitting the model.

        Example:
            >>> kmeans = KMeans(n_clusters=2)
            >>> # First fit the model
            >>> train_data = torch.tensor([[1.0, 2.0], [4.0, 5.0]])
            >>> kmeans.fit(train_data)
            >>> # Then predict on new data
            >>> new_data = torch.tensor([[1.1, 2.1], [3.9, 4.8]])
            >>> predictions = kmeans.predict(new_data)
        
src/anomalib/models/components/cluster/kmeans.py