def _check_technology_advancements_for_download(ta):
    """Checks the technology advancements input to :py:func:`download_demand_data` and
    :py:func:`download_flexibility_data`.

    :param set/list ta: The input technology advancements that will be checked. Can be
        any of: *'Slow'*, *'Moderate'*, *'Rapid'*, or *'All'*.
    :return: (*set*) -- The formatted set of technology advancements.
    :raises TypeError: if ta is not input as a set or list, or if the components of ta
        are not input as str.
    :raises ValueError: if the components of ta are not valid.
    """

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

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

    # Reformat components of ta
    ta = {x.capitalize() for x in ta}
    if "All" in ta:
        ta = {"Slow", "Moderate", "Rapid"}

    # Check that the components of ta are valid
    if not ta.issubset({"Slow", "Moderate", "Rapid"}):
        invalid_ta = ta - {"Slow", "Moderate", "Rapid"}
        raise ValueError(f'Invalid electrification scenarios: {", ".join(invalid_ta)}')

    # Return the reformatted ta
    return ta