def validate_level_indexes(num_levels, v_level_indexes, h_level_indexes):
if num_levels < <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>".format(num_levels))<EOL><DEDENT>all_levels = SortedFrozenSet(range(num_levels))<EOL>if (h_level_indexes is None) and (v_level_indexes is None):<EOL><INDENT>v_level_indexes = range(<NUM_LIT:0>, num_levels, <NUM_LIT:2>)<EOL>h_level_indexes = range(<NUM_LIT:1>, num_levels, <NUM_LIT:2>)<EOL><DEDENT>h_level_set = SortedFrozenSet(h_level_indexes)<EOL>v_level_set = SortedFrozenSet(v_level_indexes)<EOL>if h_level_indexes is None:<EOL><INDENT>h_level_indexes = all_levels - v_level_set<EOL><DEDENT>if v_level_indexes is None:<EOL><INDENT>v_level_indexes = all_levels - h_level_set<EOL><DEDENT>if len(h_level_indexes) != len(h_level_set):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if h_level_set and ((h_level_set[<NUM_LIT:0>] < <NUM_LIT:0>) or (h_level_set[-<NUM_LIT:1>] >= num_levels)):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if len(v_level_indexes) != len(v_level_set):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if v_level_set and ((v_level_set[<NUM_LIT:0>] < <NUM_LIT:0>) or (v_level_set[-<NUM_LIT:1>] >= num_levels)):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>unmentioned_levels = all_levels - v_level_set - h_level_set<EOL>if len(unmentioned_levels) > <NUM_LIT:0>:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>".format(<EOL>"<STR_LIT:U+002CU+0020>".join(map(str, unmentioned_levels))<EOL>)<EOL>)<EOL><DEDENT>if not h_level_set.isdisjoint(v_level_set):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>v_level_indexes = list(v_level_indexes)<EOL>h_level_indexes = list(h_level_indexes)<EOL>return v_level_indexes, h_level_indexes<EOL>
Ensure that v_level_indexes and h_level_indexes are consistent.

    Args:
        num_levels: The number of levels of keys in the data structure being tabulated.
        v_level_indexes: A sequence of level indexes between zero and num_levels for
            the vertical axis, or None.
        h_level_indexes: A sequence of level indexes between zero and num_levels for for
            the horizontal axis, or None.

    Returns:
        A 2-tuple containing v_level_indexes and h_level_indexes sequences.

    Raises:
        ValueError: If v_level_indexes contains duplicate values.
        ValueError: If h_level_indexes contains duplicate values.
        ValueError: If v_level_indexes contains out of range values.
        ValueError: If h_level_indexes contains out of range values.
        ValueError: If taken together v_level_indexes and h_level_indexes
            do not include all levels from zero to up to, but not including
            num_levels.
        ValueError: If v_level_indexes and h_level_indexes have items in
            common.