def __init__(
        self,
        classifier: "CLASSIFIER_NEURALNETWORK_TYPE",
        bgd_data: np.ndarray,
        layer: int | str,
        scoring_function: Literal["BerkJones", "HigherCriticism", "KolmarovSmirnov"] = "BerkJones",
        verbose: bool = True,
    ) -> None:
        """
        Create a `SubsetScanningDetector` instance which is used to the detect the presence of adversarial samples.

        :param classifier: The model being evaluated for its robustness to anomalies (e.g. adversarial samples).
        :param bgd_data: The background data used to learn a null model. Typically, dataset used to train the
                        classifier.
        :param layer: The layer from which to extract activations to perform scan.
        :param verbose: Show progress bars.
        """
        super().__init__()
        self.classifier = classifier
        self.bgd_data = bgd_data
        self.layer = layer
        self.verbose = verbose

        if scoring_function == "BerkJones":
            self.scoring_function = ScoringFunctions.get_score_bj_fast
        elif scoring_function == "HigherCriticism":
            self.scoring_function = ScoringFunctions.get_score_hc_fast
        elif scoring_function == "KolmarovSmirnov":
            self.scoring_function = ScoringFunctions.get_score_ks_fast
        else:
            raise ValueError("The provided scoring function is not supported:", scoring_function)

        # Ensure that layer is well-defined
        if classifier.layer_names is None:
            raise ValueError("No layer names identified.")

        if isinstance(layer, int):
            if layer < 0 or layer >= len(classifier.layer_names):
                raise ValueError(
                    f"Layer index {layer} is outside of range (0 to {len(classifier.layer_names) - 1} included)."
                )
            self._layer_name = classifier.layer_names[layer]
        else:
            if layer not in classifier.layer_names:
                raise ValueError(f"Layer name {layer} is not part of the graph.")
            self._layer_name = layer

        # Background data activations
        bgd_activations = self._get_activations(bgd_data, self._layer_name, batch_size=128)
        if len(bgd_activations.shape) == 4:
            dim2 = bgd_activations.shape[1] * bgd_activations.shape[2] * bgd_activations.shape[3]
            bgd_activations = np.reshape(bgd_activations, (bgd_activations.shape[0], dim2))
        self.sorted_bgd_activations = np.sort(bgd_activations, axis=0)

        # Background data scores
        pval_ranges = self._calculate_pvalue_ranges(bgd_data)
        bgd_scores = []
        for pval_range in pval_ranges:
            best_score, _, _, _ = Scanner.fgss_individ_for_nets(pval_range, score_function=self.scoring_function)
            bgd_scores.append(best_score)
        self.bgd_scores = np.asarray(bgd_scores)

        Create a `SubsetScanningDetector` instance which is used to the detect the presence of adversarial samples.

        :param classifier: The model being evaluated for its robustness to anomalies (e.g. adversarial samples).
        :param bgd_data: The background data used to learn a null model. Typically, dataset used to train the
                        classifier.
        :param layer: The layer from which to extract activations to perform scan.
        :param verbose: Show progress bars.
        
art/defences/detector/evasion/subsetscanning/detector.py