def reverse_list_dictionary(to_reverse, keys):
    """Transforms a list of dictionaries into a dictionary of lists.

    Additionally, if the initial list contains None instead of dictionaries,
    the dictionnary will contain lists of None.
    Mainly used in the measure.py file.

    Args:
        to_reverse (list): List to reverse, should contain dictionaries (or None)
        keys (list): Keys of the dictionaries inside the list.

    Returns:
        Dictionary.
    """
    if to_reverse[0] is None:
        to_reverse = {k: [None for _ in range(len(to_reverse))] for k in keys}
    else:
        to_reverse = {k: [to_reverse[n][k] for n in range(len(to_reverse))] for k in keys}
    return to_reverse