from typing import List
from typing import Any


def flatten(list_: List[Any]) -> List[Any]:
    """Flattens a nested list of tag predictions."""
    result = []

    for sub in list_:
        if sub and isinstance(sub, list) and isinstance(sub[0], list):
            result.extend(flatten(sub))
        elif isinstance(sub, list):
            result.extend(sub)
        else:
            result.append(sub)

    return result