def _get_penultimate_layer_activations(self, x: np.ndarray) -> np.ndarray:
        """
        Return the output of the second to last layer for input `x`.

        :param x: Input for computing the activations.
        :return: The output of `layer`, where the first dimension is the batch size corresponding to `x`.
        """
        if self.layer_names is not None:
            penultimate_layer = len(self.layer_names) - 2
        else:  # pragma: no cover
            raise ValueError("No layer names found.")
        return self.get_activations(x, penultimate_layer, batch_size=self.batch_size, framework=False)

        Return the output of the second to last layer for input `x`.

        :param x: Input for computing the activations.
        :return: The output of `layer`, where the first dimension is the batch size corresponding to `x`.
        
art/estimators/poison_mitigation/neural_cleanse/keras.py