@@ -12,8 +12,10 @@ from typing_extensions import Self
1212from google .protobuf .message import Message
1313from tensorflow import (
1414 data as data ,
15+ debugging as debugging ,
1516 experimental as experimental ,
1617 feature_column as feature_column ,
18+ image as image ,
1719 initializers as initializers ,
1820 io as io ,
1921 keras as keras ,
@@ -26,13 +28,15 @@ from tensorflow._aliases import (
2628 AnyArray ,
2729 DTypeLike ,
2830 IntArray ,
31+ IntTensorCompatible ,
2932 RaggedTensorLike ,
3033 ScalarTensorCompatible ,
3134 ShapeLike ,
3235 Signature ,
3336 Slice ,
3437 SparseTensorCompatible ,
3538 TensorCompatible ,
39+ TensorLike ,
3640 UIntTensorCompatible ,
3741)
3842from tensorflow .autodiff import GradientTape as GradientTape
@@ -448,17 +452,35 @@ def ones_like(
448452
449453def reshape (tensor : TensorCompatible , shape : ShapeLike | Tensor , name : str | None = None ) -> Tensor : ...
450454def reverse (tensor : TensorCompatible , axis : IntTensorCompatible , name : str | None = None ) -> Tensor : ...
455+
456+ _ElemT = TypeVar ("_ElemT" , bound = TensorLike )
457+ _RetT = TypeVar ("_RetT" , bound = TensorLike )
458+
459+ @overload
451460def map_fn (
452- fn : Callable [TensorLike | TensorCompatible , TensorLike ],
453- elems : TensorLike | TensorCompatible ,
461+ fn : Callable [[ _ElemT ], _RetT ],
462+ elems : _ElemT ,
454463 dtype : DTypeLike | None = None ,
455464 parallel_iterations : int | None = None ,
456- back_prop : bool = True ,
457- swap_memory : bool = False ,
458- infer_shape : bool = True ,
465+ back_prop : _bool = True ,
466+ swap_memory : _bool = False ,
467+ infer_shape : _bool = True ,
459468 name : str | None = None ,
460- fn_output_signature : Signature = None ,
461- ) -> Tensor : ...
469+ fn_output_signature : Signature | None = None ,
470+ ) -> _RetT : ...
471+ @overload
472+ def map_fn (
473+ fn : Callable [[Tensor ], _RetT ],
474+ elems : TensorCompatible ,
475+ dtype : DTypeLike | None = None ,
476+ parallel_iterations : int | None = None ,
477+ back_prop : _bool = True ,
478+ swap_memory : _bool = False ,
479+ infer_shape : _bool = True ,
480+ name : str | None = None ,
481+ fn_output_signature : Signature | None = None ,
482+ ) -> _RetT : ...
483+
462484def pad (
463485 tensor : TensorCompatible ,
464486 paddings : Tensor | IntArray | Iterable [Iterable [int ]],
0 commit comments