nested_map(x: Union[ivy.Array, ivy.NativeArray, Iterable], fn: Callable, include_derived: bool = False, max_depth: Optional[int] = None, depth: int = 0) → Union[ivy.Array, ivy.NativeArray, Iterable]¶
Applies a function on x in a nested manner, whereby all dicts, lists and tuples are traversed to their lowest leaves before applying the method and returning x. If x is not nested, the method is applied to x directly.
x (any) – The item to apply the mapped function to.
fn (callable) – The function to map onto x.
include_derived (bool, optional) – Whether to also recursive for classes derived from tuple, list and dict. Default is False.
max_depth (int, optional) – The maximum nested depth to reach. Default is 1. Increase this if the nest is deeper.
depth (int, used internally) – Placeholder for tracking the recursive depth, do not yet this parameter.
x following the applicable of fn to it’s nested leaves, or x itself if x is not nested.