def _check_electrification_scenarios_for_download(es):
    """Checks the electrification scenarios input to :py:func:`download_demand_data`
    and :py:func:`download_flexibility_data`.

    :param set/list es: The input electrification scenarios that will be checked. Can
        be any of: *'Reference'*, *'Medium'*, *'High'*, or *'All'*.
    :return: (*set*) -- The formatted set of electrification scenarios.
    :raises TypeError: if es is not input as a set or list, or if the components of es
        are not input as str.
    :raises ValueError: if the components of es are not valid.
    """

    # Check that the input is of an appropriate type
    if not isinstance(es, (set, list)):
        raise TypeError("Electrification scenarios must be input as a set or list.")

    # Check that the components of es are str
    if not all(isinstance(x, str) for x in es):
        raise TypeError("Individual electrification scenarios must be input as a str.")

    # Reformat components of es
    es = {x.capitalize() for x in es}
    if "All" in es:
        es = {"Reference", "Medium", "High"}

    # Check that the components of es are valid
    if not es.issubset({"Reference", "Medium", "High"}):
        invalid_es = es - {"Reference", "Medium", "High"}
        raise ValueError(f'Invalid electrification scenarios: {", ".join(invalid_es)}')

    # Return the reformatted es
    return es