def detect(self, x: np.ndarray, batch_size: int = 128, **kwargs) -> tuple[np.ndarray, np.ndarray]:  # type: ignore
        """
        Detect whether given samples are adversarial

        :param x: Input samples
        :param batch_size: Batch size for processing
        :return: (report, is_adversarial):
            where report containing detection results
            where is_adversarial is a boolean list indicating whether samples are adversarial or not
        """
        if self.threshold is None:
            raise ValueError("Detector has not been fitted. Call fit() before detect().")

        similarities = self._get_metrics(x, batch_size)

        report = similarities[:, self.var_K - 1]
        is_adversarial = report < self.threshold

        return report, is_adversarial

        Detect whether given samples are adversarial

        :param x: Input samples
        :param batch_size: Batch size for processing
        :return: (report, is_adversarial):
            where report containing detection results
            where is_adversarial is a boolean list indicating whether samples are adversarial or not
        
art/defences/detector/evasion/beyond_detector.py