def compute_anomaly_mask(
        self,
        z: list[torch.Tensor],
        window_size: int = 7,
        binomial_probability_thr: float = 0.5,
        high_precision: bool = False,
    ) -> torch.Tensor:
        """Generate NFA-based anomaly segmentation mask from latent variables.

        This optional method implements the Number of False Alarms (NFA) approach from
        the U-Flow paper. It is slower than the default likelihood method but provides
        unsupervised binary segmentation.

        The method:
        1. Applies binomial testing on local windows around each pixel
        2. Computes NFA statistics based on concentration of candidate pixels
        3. Generates binary segmentation mask

        Args:
            z (list[torch.Tensor]): List of latent tensors from U-Flow model
            window_size (int, optional): Size of local window for binomial test.
                Defaults to ``7``.
            binomial_probability_thr (float, optional): Probability threshold for
                binomial test. Defaults to ``0.5``.
            high_precision (bool, optional): Whether to use high precision NFA
                computation. Slower but more accurate. Defaults to ``False``.

        Returns:
            torch.Tensor: Binary anomaly mask of shape ``(batch_size, 1, height,
                width)``
        """
        log_prob_l = [
            self.binomial_test(zi, window_size / (2**scale), binomial_probability_thr, high_precision)
            for scale, zi in enumerate(z)
        ]

        log_prob_l_up = torch.cat(
            [F.interpolate(lpl, size=self.input_size, mode="bicubic", align_corners=True) for lpl in log_prob_l],
            dim=1,
        )

        log_prob = torch.sum(log_prob_l_up, dim=1, keepdim=True)

        log_number_of_tests = torch.log10(torch.sum(torch.tensor([zi.shape[-2] * zi.shape[-1] for zi in z])))
        log_nfa = log_number_of_tests + log_prob

        anomaly_score = -log_nfa

        return anomaly_score < 0
Generate NFA-based anomaly segmentation mask from latent variables.

        This optional method implements the Number of False Alarms (NFA) approach from
        the U-Flow paper. It is slower than the default likelihood method but provides
        unsupervised binary segmentation.

        The method:
        1. Applies binomial testing on local windows around each pixel
        2. Computes NFA statistics based on concentration of candidate pixels
        3. Generates binary segmentation mask

        Args:
            z (list[torch.Tensor]): List of latent tensors from U-Flow model
            window_size (int, optional): Size of local window for binomial test.
                Defaults to ``7``.
            binomial_probability_thr (float, optional): Probability threshold for
                binomial test. Defaults to ``0.5``.
            high_precision (bool, optional): Whether to use high precision NFA
                computation. Slower but more accurate. Defaults to ``False``.

        Returns:
            torch.Tensor: Binary anomaly mask of shape ``(batch_size, 1, height,
                width)``
        
src/anomalib/models/image/uflow/anomaly_map.py