from __future__ import annotations

from collections.abc import Callable, Sequence
from sys import version_info as version_info
from typing import Any, NoReturn, TypeVar

from typing_extensions import TypeAlias

from .._typing.shape import ShapeLike

_T = TypeVar("_T")
NestTL1: TypeAlias = Sequence[_T] | _T
NestTL2: TypeAlias = NestTL1[NestTL1[_T]]
NestTL3: TypeAlias = NestTL1[NestTL2[_T]]
NestTL4: TypeAlias = NestTL1[NestTL3[_T]]
NestTL5: TypeAlias = NestTL1[NestTL4[_T]]
NestTL6: TypeAlias = NestTL1[NestTL5[_T]]

NestStructure: TypeAlias = NestTL6[_T]

_RetT = TypeVar("_RetT")

def convert_to_list(value: Any, n: Any, name: Any, dtype: Any = ...) -> Any: ...
def is_sequence(seq: Any) -> bool: ...
def flatten(nest: NestStructure[_T]) -> list[_T]: ...
def pack_sequence_as(structure: NestStructure[_T], flat_sequence: list[_T]) -> NestStructure[_T]: ...
def map_structure(func: Callable[[_T], _RetT], *structure: NestStructure[_T]) -> NestStructure[_RetT]: ...
def hold_mutable_vars(structure: NestStructure[_T]) -> Any: ...
def copy_mutable_vars(structure: NestStructure[_T]) -> Any: ...
def assert_same_structure(nest1: Any, nest2: Any, check_types: bool = ...) -> None: ...
def get_shape_tensor_inputs(inputs: Any, attrs: Any, shape: Any, op_type: Any) -> Any: ...
def convert_shape_to_list(shape: ShapeLike) -> list[int]: ...
def check_shape(shape: ShapeLike) -> NoReturn: ...
def try_set_static_shape_tensor(tensor: Any, shape: Any) -> None: ...
def try_get_constant_shape_from_tensor(shape_tensor: Any) -> None: ...
def get_inputs_outputs_in_block(block: Any) -> Any: ...
