def split_in_layers(network, layers_concat):
    """
    Split a Tensor containing the concatenated layer activations for a
    minibatch into a list containing the activations of layer ``i`` at
    index ``i``.
    Args:
        network: network object
        layers_concat (torch.Tensor): a tensor of dimension
        :math:`B \times \sum_{l=1}^L n_l` containing the concatenated
            layer activations.

    Returns (list): A list containing values of ``layers_concat`` corresponding
    to the activations of layer ``i`` at index ``i``

    """
    layer_output_dims = [l.weights.shape[0] for l in network.layers]
    start_output_limits = [sum(layer_output_dims[:i]) for i in
                           range(len(network.layers))]
    end_output_limits = [sum(layer_output_dims[:i + 1]) for i in
                         range(len(network.layers))]
    if len(layers_concat.shape) == 1:
        # to avoid errors when batch_size==1
        layers_concat = layers_concat.unsqueeze(0)
    return [layers_concat[:, start_output_limits[i]:end_output_limits[i]]
                             for i in range(len(network.layers))]