def _check_flexibility_scenario(flex):
    """Checks the flexibility scenario input to
    :py:func:`partition_flexibility_by_sector`.

    :param str flex: The input flexibility scenario that will be checked. Can be any of:
        *'Base'* or *'Enhanced'*.
    :return: (*set*) -- The formatted set of flexibility scenarios.
    :raises TypeError: if flex is not input as a set or list, or if the components of
        flex are not input as str.
    :raises ValueError: if the components of flex are not valid.
    """

    # Check that the input is of an appropriate type
    if not isinstance(flex, str):
        raise TypeError("Flexibility scenario must be input as a str.")

    # Reformat flex
    flex = flex.capitalize()

    # Check that flex is valid
    if flex not in {"Base", "Enhanced"}:
        raise ValueError(f"{flex} is not a valid flexibility scenario.")

    # Return the reformatted flex
    return flex