def _check_sectors(sect):
    """Checks the sectors input to :py:func:`partition_demand_by_sector` and
    :py:func:`partition_flexibility_by_sector`.

    :param set/list sect: The input sectors. Can be any of: *'Transportation'*,
        *'Residential'*, *'Commercial'*, *'Industrial'*, or *'All'*.
    :return: (*set*) -- The formatted set of sectors.
    :raises TypeError: if sect is not input as a set or list, or if the components of
        sect are not input as str.
    :raises ValueError: if the components of sect are not valid.
    """

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

    # Check that the components of sect are str
    if not all(isinstance(x, str) for x in sect):
        raise TypeError("Each individual sector must be input as a str.")

    # Reformat components of sect
    sect = {x.capitalize() for x in sect}
    if "All" in sect:
        sect = {"Transportation", "Residential", "Commercial", "Industrial"}

    # Check that the components of sect are valid
    if not sect.issubset({"Transportation", "Residential", "Commercial", "Industrial"}):
        invalid_sect = sect - {
            "Transportation",
            "Residential",
            "Commercial",
            "Industrial",
        }
        raise ValueError(f'Invalid sectors: {", ".join(invalid_sect)}')

    # Return the reformatted sect
    return sect