| from collections.abc import Iterable | |
| from typing import Any | |
| def _to_list(x: list[Any] | tuple[Any] | Any) -> list[Any] | tuple[Any]: | |
| """Converts x to a list if it is not already a list or tuple.""" | |
| if isinstance(x, (list | tuple)): | |
| return x | |
| return [x] | |
| def _flatten_list(x: Iterable[Iterable[Any]]) -> list[Any]: | |
| """Flattens a list of lists.""" | |
| return [item for sublist in x for item in sublist] | |