def get_activations(  # type: ignore
        self, x: np.ndarray, layer: int | str, batch_size: int = 128, framework: bool = False
    ) -> np.ndarray | None:
        """
        Return the output of the specified layer for input `x`. `layer` is specified by layer index (between 0 and
        `nb_layers - 1`) or by name. The number of layers can be determined by counting the results returned by
        calling `layer_names`.

        :param x: Input for computing the activations.
        :param layer: Layer for computing the activations.
        :param batch_size: Batch size.
        :param framework: Return activation as tensor.
        :return: The output of `layer`, where the first dimension is the batch size corresponding to `x`.
        """
        import tensorflow as tf
        from art.config import ART_NUMPY_DTYPE

        if not isinstance(self._model, tf.keras.models.Sequential):  # pragma: no cover
            raise ValueError("Method get_activations is not supported for non-Sequential models.")

        i_layer = None
        if self.layer_names is None:  # pragma: no cover
            raise ValueError("No layer names identified.")

        if isinstance(layer, six.string_types):
            if layer not in self.layer_names:  # pragma: no cover
                raise ValueError(f"Layer name {layer} is not part of the graph.")
            for i_name, name in enumerate(self.layer_names):
                if name == layer:
                    i_layer = i_name
                    break
        elif isinstance(layer, int):
            if layer < -len(self.layer_names) or layer >= len(self.layer_names):  # pragma: no cover
                raise ValueError(
                    f"Layer index {layer} is outside of range (-{len(self.layer_names)} "
                    f"to {len(self.layer_names) - 1})."
                )
            i_layer = layer
        else:  # pragma: no cover
            raise TypeError("Layer must be of type `str` or `int`.")

        activation_model = tf.keras.Model(self._model.layers[0].input, self._model.layers[i_layer].output)

        # Apply preprocessing
        x_preprocessed, _ = self._apply_preprocessing(x=x, y=None, fit=False)

        if framework:
            if isinstance(x_preprocessed, tf.Tensor):
                return activation_model(x_preprocessed, training=False)
            return activation_model(tf.convert_to_tensor(x_preprocessed), training=False)

        # Determine shape of expected output and prepare array
        output_shape = self._model.layers[i_layer].output_shape
        activations = np.zeros((x_preprocessed.shape[0],) + output_shape[1:], dtype=ART_NUMPY_DTYPE)

        # Get activations with batching
        for batch_index in range(int(np.ceil(x_preprocessed.shape[0] / float(batch_size)))):
            begin, end = (
                batch_index * batch_size,
                min((batch_index + 1) * batch_size, x_preprocessed.shape[0]),
            )
            activations[begin:end] = activation_model([x_preprocessed[begin:end]], training=False).numpy()

        return activations

        Return the output of the specified layer for input `x`. `layer` is specified by layer index (between 0 and
        `nb_layers - 1`) or by name. The number of layers can be determined by counting the results returned by
        calling `layer_names`.

        :param x: Input for computing the activations.
        :param layer: Layer for computing the activations.
        :param batch_size: Batch size.
        :param framework: Return activation as tensor.
        :return: The output of `layer`, where the first dimension is the batch size corresponding to `x`.
        
art/estimators/classification/tensorflow.py