def normalize_concatenate_activations(
        activations_dict: dict[str, "torch.Tensor"],
        list_layer_names: list[str],
    ) -> "torch.Tensor":
        """
        Takes a dictionary `activations_dict' of activation values of different layers for an input batch and Returns
        a tensor where all activation values are normalised layer-wise and flattened to a vector for
        each input of the batch.

        :param activations_dict: dict containing the activations at different layers.
        :param list_layer_names: Layers' names for fetching the activations.
        :return: The activations after normalisation and flattening, where the first dimension is the batch size.
        """

        import torch

        activation_vectors = []
        for name in list_layer_names:
            temp_activation = activations_dict[name]
            size_temp_activation = list(temp_activation.size())
            norm_factor_layer = size_temp_activation[2] * size_temp_activation[3]
            norm_temp_activation = torch.sqrt(torch.sum(temp_activation**2, dim=1, keepdim=True)) + EPS
            temp_activation_n_channel = temp_activation / norm_temp_activation
            temp_activation_n_layer_channel = temp_activation_n_channel / np.sqrt(norm_factor_layer)
            temp_activation_n_layer_channel_flat = temp_activation_n_layer_channel.view(size_temp_activation[0], -1)
            activation_vectors.append(temp_activation_n_layer_channel_flat)

        activation_vectors_flattened = torch.cat(activation_vectors, dim=1)
        return activation_vectors_flattened

        Takes a dictionary `activations_dict' of activation values of different layers for an input batch and Returns
        a tensor where all activation values are normalised layer-wise and flattened to a vector for
        each input of the batch.

        :param activations_dict: dict containing the activations at different layers.
        :param list_layer_names: Layers' names for fetching the activations.
        :return: The activations after normalisation and flattening, where the first dimension is the batch size.
        
art/defences/trainer/adversarial_trainer_oaat_pytorch.py