# General

Collection of general Ivy functions.

ivy.all_equal(*xs, equality_matrix=False)[source]

Determines whether the inputs are all equal.

Parameters
• xs (`Iterable`[`Any`]) – inputs to compare.

• equality_matrix (`bool`) – Whether to return a matrix of equalities comparing each input with every other. (default: `False`) Default is `False`.

Return type

`Union`[`bool`, `Array`, `NativeArray`]

Returns

ret – Boolean, whether or not the inputs are equal, or matrix array of booleans if equality_matrix=True is set.

Examples

With `ivy.Array` inputs:

```>>> x1 = ivy.array([1, 1, 0, 0, 1, -1])
>>> x2 = ivy.array([1, 1, 0, 0, 1, -1])
>>> y = ivy.all_equal(x1, x2)
>>> print(y)
True
```
```>>> x1 = ivy.array([0, 0])
>>> x2 = ivy.array([0, 0])
>>> x3 = ivy.array([1, 0])
>>> y = ivy.all_equal(x1, x2, x3, equality_matrix=True)
>>> print(y)
ivy.array([[ True,  True, False],
[ True,  True, False],
[False, False,  True]])
```

With one `ivy.Container` inputs:

```>>> x1 = ivy.Container(a=ivy.array([0, 0, -1, 1, 0]),
...                    b=ivy.array([0, 0, -1, 1, 0]))
>>> x2 = ivy.array([0, 0, -1, 1, 0])
>>> y = ivy.all_equal(x1, x2, equality_matrix=False)
>>> print(y)
{
a: true,
b: true
}
```

With multiple `ivy.Container` inputs:

```>>> x1 = ivy.Container(a=ivy.array([1, 0, 1, 1]),
...                    b=ivy.array([1, 0, 0, 1]))
>>> x2 = ivy.Container(a=ivy.array([1, 0, 1, 1]),
...                    b=ivy.array([1, 0, -1, -1]))
>>> y = ivy.all_equal(x1, x2, equality_matrix=False)
>>> print(y)
{
a: true,
b: false
}
```
ivy.arg_info(fn, *, name=None, idx=None)[source]

Return the index and inspect.Parameter representation of the specified argument. In the form of a dict with keys “idx” and “param”.

Parameters
• fn (`Callable`) – The function to retrieve the argument information for

• name (`Optional`[`str`]) – The name of the argument (default: `None`)

• idx (`Optional`[`int`]) – the index of the argument in the inputs (default: `None`)

Returns

ret – a dict containing the idx, and the inspect.Parameter for the argument, which itself contains the parameter name, type, and other helpful information.

Gets the expected keyword arguments for a function or class constructor.

Parameters

receiver – Function or class constructor

Returns

ret – List containing the keyword arguments’ names for a function or class constructor

Examples

```>>> x = ivy.arg_names(ivy.tan)
>>> print(x)
['x', 'out']
```
```>>> x = ivy.arg_names(ivy.optimizers.Adam)
>>> print(x)
['lr', 'beta1', 'beta2', 'epsilon', 'inplace',
```
ivy.array_equal(x0, x1, /)[source]

Determines whether two input arrays are equal across all elements.

Parameters
• x0 (`Union`[`Array`, `NativeArray`]) – The first input array to compare.

• x1 (`Union`[`Array`, `NativeArray`]) – The second input array to compare.

Return type

`bool`

Returns

ret – Boolean, whether or not the input arrays are equal across all elements.

Examples

```>>> x = ivy.array([1,0,1])
>>> y = ivy.array([1,0,-1])
>>> z = ivy.array_equal(x,y)
>>> print(z)
False
```
```>>> a = ivy.array([1, 2])
>>> b = ivy.array([1, 2])
>>> c = ivy.array_equal(a,b)
>>> print(c)
True
```
```>>> i = ivy.array([1, 2])
>>> j = ivy.array([1, 2, 3])
>>> k = ivy.array_equal(i,j)
>>> print(k)
False
```
ivy.assert_supports_inplace(x, /)[source]

Asserts that inplace operations are supported for x, else raises exception.

Parameters

x (`Union`[`Array`, `NativeArray`]) – Input variable or array to check for inplace support for.

Return type

`bool`

Returns

ret – True if support, raises exception otherwise

ivy.cache_fn(func)[source]

Decorator to wrap a function, such that computed outputs are cached to avoid recalculating them later.

Parameters

func (`Callable`) – The function to wrap, whose output should be cached for later.

Return type

`Callable`

Returns

ret – The newly cache wrapped function.

Examples

With positional arguments only:

```>>> def my_sum(val1:float, val2:float)->float: return val1 + val2
>>> cached_sum = ivy.cache_fn(my_sum)
>>> print(cached_sum(3, 5)) # Compute the output
8
```
```>>> print(cached_sum(10, 34)) # Compute the output
44
```
```>>> print(cached_sum(3, 5)) # Returns the cached value
8
```
```>>> print(cached_sum(5, 3)) # Compute the output
8
```

With keyword arguments:

```>>> def line_eq(x:float, /, *, slp:float=2, itc:float=0)->float: return x*slp+itc
>>> cached_line_eq = ivy.cache_fn(line_eq)
>>> print(cached_line_eq(3, itc=5, slp=2))
11
```
```>>> print(cached_line_eq(3, slp=2, itc=5)) # Returns the cached value
11
```

Note: providing keyword arguments by position, or using the default keyword argument values will prevent the cache from being used.

```>>> print(cached_line_eq(5, slp=2)) # Output is re-computed
10
```
```>>> print(cached_line_eq(5)) # Output is re-computed
10
```
ivy.clip_matrix_norm(x, max_norm, /, *, p=2.0, out=None)[source]

Clips (limits) the matrix norm of an array.

Parameters
• x (`Union`[`Array`, `NativeArray`]) – Input array containing elements to clip.

• max_norm (`float`) – The maximum value of the array norm.

• p (`float`) – The p-value for computing the p-norm. Default is 2. (default: `2.0`)

• out (`Optional`[`Array`]) – optional output array, for writing the result to. It must have a shape that the (default: `None`) inputs broadcast to.

Return type

`Array`

Returns

ret – An array with the matrix norm downscaled to the max norm if needed.

Functional Examples

With `ivy.Array` input:

```>>> x = ivy.array([[0., 1., 2.]])
>>> y = ivy.clip_matrix_norm(x, 2.0)
>>> print(y)
ivy.array([[0.   , 0.894, 1.79 ]])
```
```>>> x = ivy.array([[0.1, -1.2, 3.7], [0., 7.3, -0.5]])
>>> y = ivy.clip_matrix_norm(x, 3.0, p=1.0)
>>> print(y)
ivy.array([[ 0.0353, -0.424 ,  1.31  ],
[ 0.    ,  2.58  , -0.176 ]])
```
```>>> x = ivy.array([[[5., 4.], [-2., 6.]],
...                [[3., 7.], [0., -5.]]])
>>> y = ivy.empty((2, 2, 2))
>>> y = ivy.clip_matrix_norm(x, 0.5, p=2.0)
>>> print(y)
ivy.array([[[ 0.339,  0.271],
[-0.135,  0.406]],
[[ 0.168,  0.391],
[ 0.   , -0.279]]])
```
```>>> x = ivy.array([[0., 1.],
...                [2., 3.]])
>>> ivy.clip_matrix_norm(x, 5.0, p=1.0, out=x)
>>> print(x)
ivy.array([[0., 1.],
[2., 3.]])
```

With `ivy.Container` input:

```>>> x = ivy.Container(a=ivy.array([[0., 1., 2.]]),
...                   b=ivy.array([[3., 4., 5.]]))
>>> y = ivy.clip_matrix_norm(x, 2.0)
>>> print(y)
{
a: ivy.array([[0., 0.894, 1.79]]),
b: ivy.array([[0.849, 1.13, 1.41]])
}
```
ivy.clip_vector_norm(x, max_norm, /, *, p=2.0, out=None)[source]

Clips (limits) the vector p-norm of an array.

Parameters
• x (`Union`[`Array`, `NativeArray`]) – array, input array containing elements to clip.

• max_norm (`float`) – float, the maximum value of the array norm.

• p (`float`) – optional float, the p-value for computing the p-norm. Default is 2. (default: `2.0`)

• out (`Optional`[`Array`]) – optional output array, for writing the result to. It must have a shape that the (default: `None`) inputs broadcast to.

Return type

`Array`

Returns

ret – An array with the vector norm downscaled to the max norm if needed.

Functional Examples

With `ivy.Array` input:

```>>> x = ivy.array([0., 1., 2.])
>>> y = ivy.clip_vector_norm(x, 2.0)
>>> print(y)
ivy.array([0.   , 0.894, 1.79 ])
```
```>>> x = ivy.array([0.5, -0.7, 2.4])
>>> y = ivy.clip_vector_norm(x, 3.0, p=1.0)
>>> print(y)
ivy.array([ 0.417, -0.583,  2.   ])
```
```>>> x = ivy.array([[[0., 0.], [1., 3.], [2., 6.]],
...                [[3., 9.], [4., 12.], [5., 15.]]])
>>> y = ivy.zeros(((2, 3, 2)))
>>> ivy.clip_vector_norm(x, 4.0, p=1.0, out=y)
>>> print(y)
ivy.array([[[0.    , 0.    ],
[0.0667, 0.2   ],
[0.133 , 0.4   ]],
[[0.2   , 0.6   ],
[0.267 , 0.8   ],
[0.333 , 1.    ]]])
```
```>>> x = ivy.array([[1.1, 2.2, 3.3],
...                [-4.4, -5.5, -6.6]])
>>> ivy.clip_vector_norm(x, 1.0, p=3.0, out=x)
>>> print(x)
ivy.array([[ 0.131,  0.263,  0.394],
[-0.526, -0.657, -0.788]])
```

With `ivy.Container` input:

```>>> x = ivy.Container(a=ivy.array([0., 1., 2.]),
...                   b=ivy.array([3., 4., 5.]))
>>> y = ivy.clip_vector_norm(x, 2.0)
>>> print(y)
{
a: ivy.array([0., 0.894, 1.79]),
b: ivy.array([0.849, 1.13, 1.41])
}
```
ivy.container_types()[source]

Summary.

Returns

ret – a key-value structure, and exposes public methods .keys(), .values() and items().

ivy.current_backend_str()[source]

Return framework string

Return type

`Optional`[`str`]

Returns

ret – The framework string.

ivy.default(x, /, default_val, *, catch_exceptions=False, rev=False, with_callable=False)[source]

Returns x provided it exists (is not None), else returns default value.

Parameters
• x (`Any`) – Input which may or may not exist (be None).

• default_val (`Any`) – The default value.

• catch_exceptions (`bool`) – Whether to catch exceptions from callable x. Default is `False`. (default: `False`)

• rev (`bool`) – Whether to reverse the input x and default_val. Default is `False`. (default: `False`)

• with_callable (`bool`) – Whether either of the arguments might be callable functions. (default: `False`) Default is `False`.

Return type

`Any`

Returns

ret – x if x exists (is not None), else default.

Functional Examples

With `Any` input:

```>>> x = None
>>> y = ivy.default(x, "default_string")
>>> print(y)
default_string
```
```>>> x = ""
>>> y = ivy.default(x, "default_string")
>>> print(y)
```
```>>> x = ivy.array([4, 5, 6])
>>> y = ivy.default(x, ivy.array([1, 2, 3]), rev=True)
>>> print(y)
ivy.array([1, 2, 3])
```
```>>> x = lambda: ivy.array([1, 2, 3])
>>> y = ivy.default(x, ivy.array([4, 5, 6]), with_callable=True)
>>> print(y)
ivy.array([1, 2, 3])
```
```>>> x = lambda: None
>>> y = ivy.default(x, lambda: ivy.array([1, 2, 3]), with_callable=True)
>>> print(y)
ivy.array([1, 2, 3])
```
```>>> x = lambda: None
>>> y = ivy.default(x, lambda: ivy.array([1, 2, 3]), catch_exceptions=True)
>>> print(y)
ivy.array([1, 2, 3])
```
```>>> x = lambda a, b: a + b
>>> y = ivy.default(x, lambda: ivy.array([1, 2, 3]), with_callable=True,
...                 catch_exceptions=True)
>>> print(y)
ivy.array([1, 2, 3])
```
```>>> x = lambda a, b: a + b
>>> y = ivy.default(x, lambda: ivy.array([1, 2, 3]), with_callable=True,
...                 catch_exceptions=True, rev=True)
>>> print(y)
ivy.array([1, 2, 3])
```
ivy.einops_rearrange(x, pattern, /, *, out=None, **axes_lengths)[source]

Perform einops rearrange operation on input array x.

Parameters
• x (`Union`[`Array`, `NativeArray`]) – Input array to be re-arranged.

• pattern (`str`) – Rearrangement pattern.

• axes_lengths (`Dict`[`str`, `int`]) – Any additional specifications for dimensions.

• out (`Optional`[`Array`]) – optional output array, for writing the result to. It must have a shape that the (default: `None`) inputs broadcast to.

Return type

`Array`

Returns

ret – New array with einops.rearrange having been applied.

ivy.einops_reduce(x, pattern, reduction, /, *, out=None, **axes_lengths)[source]

Perform einops reduce operation on input array x.

Parameters
• x (`Union`[`Array`, `NativeArray`]) – Input array to be reduced.

• pattern (`str`) – Reduction pattern.

• reduction (`Union`[`str`, `Callable`]) – One of available reductions (‘min’, ‘max’, ‘sum’, ‘mean’, ‘prod’), or callable.

• axes_lengths (`Dict`[`str`, `int`]) – Any additional specifications for dimensions.

• out (`Optional`[`Array`]) – optional output array, for writing the result to. It must have a shape that the (default: `None`) inputs broadcast to.

Return type

`Array`

Returns

ret – New array with einops.reduce having been applied.

Examples

With `ivy.Array` input:

```>>> x = ivy.array([[-4.47, 0.93, -3.34],
...                [3.66, 24.29, 3.64]])
>>> reduced = ivy.einops_reduce(x, 'a b -> b', 'mean')
>>> print(reduced)
ivy.array([-0.405, 12.6  ,  0.15 ])
```

With `ivy.Container` input:

```>>> x = ivy.Container(a=ivy.array([[-4.47, 0.93, -3.34],
...                                [3.66, 24.29, 3.64]]),
...                    b=ivy.array([[4.96, 1.52, -10.67],
...                                 [4.36, 13.96, 0.3]]))
>>> reduced = ivy.einops_reduce(x, 'a b -> a', 'mean')
>>> print(reduced)
{
a: ivy.array([-2.29, 10.5]),
b: ivy.array([-1.4, 6.21])
}
```
ivy.einops_repeat(x, pattern, /, *, out=None, **axes_lengths)[source]

Perform einops repeat operation on input array x.

Parameters
• x (`Union`[`Array`, `NativeArray`]) – Input array to be repeated.

• pattern (`str`) – Rearrangement pattern.

• axes_lengths (`Dict`[`str`, `int`]) – Any additional specifications for dimensions.

• out (`Optional`[`Array`]) – optional output array, for writing the result to. It must have a shape that the (default: `None`) inputs broadcast to.

Return type

`Array`

Returns

ret – New array with einops.repeat having been applied.

Examples

With `ivy.Array` input:

```>>> x = ivy.array([1, 2, 3, 4])
>>> repeated = ivy.einops_repeat(x, 'a -> b a', b=2)
>>> print(repeated)
ivy.array([[1, 2, 3, 4],
[1, 2, 3, 4]])
```

With `ivy.Container` input:

```>>> x = ivy.Container(a=ivy.array([[4,5],
...                                [1, 3]]),
...                    b=ivy.array([[9, 10],
...                                 [4, 2]]))
>>> repeated = ivy.einops_repeat(x, 'h w -> h (c w)', c=2)
>>> print(repeated)
{
a: ivy.array([[4, 5, 4, 5],
[1, 3, 1, 3]]),
b: ivy.array([[9, 10, 9, 10],
[4, 2, 4, 2]])
}
```
ivy.exists(x)[source]

Simple check as to whether the input is None or not.

Parameters

x (`Any`) – Input to check.

Return type

`bool`

Returns

ret – True if x is not None, else False.

Examples

With `Any` input:

```>>> x = None
>>> y = ivy.exists(x)
>>> print(y)
False
```
```>>> x = ""
>>> y = ivy.exists(x)
>>> print(y)
True
```
```>>> x = []
>>> y = ivy.exists(x)
>>> print(y)
True
```
```>>> x = 1
>>> y = ivy.exists(x)
>>> print(y)
True
```
```>>> x = "abc"
>>> y = ivy.exists(x)
>>> print(y)
True
```
```>>> x = [1, 0, -1, 1]
>>> y = ivy.exists(x)
>>> print(y)
True
```
```>>> x = ivy.array([1, 2, 3, 1.2])
>>> y = ivy.exists(x)
>>> print(y)
True
```

With a mix of `ivy.Container` and `Any` input:

```>>> x = ivy.Container(a=None, b=None)
>>> y = ivy.exists(x)
>>> print(y)
True
```
```>>> x = ivy.Container(a=None, b="")
>>> y = ivy.exists(x)
>>> print(y)
True
```
```>>> x = ivy.Container(a=123, b="")
>>> y = ivy.exists(x)
>>> print(y)
True
```
ivy.fourier_encode(x, max_freq, /, *, num_bands=4, linear=False, concat=True, flatten=False)[source]

Pads an array with fourier encodings.

Parameters
• x (`Union`[`Array`, `NativeArray`]) – Input array to encode.

• max_freq (`Union`[`float`, `Array`, `NativeArray`]) – The maximum frequency of the encoding.

• num_bands (`int`) – The number of frequency bands for the encoding. Default is 4. (default: `4`)

• linear (`bool`) – Whether to space the frequency bands linearly as opposed to geometrically. (default: `False`) Default is `False`.

• concat (`bool`) – Whether to concatenate the position, sin and cos values, or return seperately. (default: `True`) Default is `True`.

• flatten (`bool`) – Whether to flatten the position dimension into the batch dimension. Default is (default: `False`) False.

Return type

`Union`[`Array`, `NativeArray`, `Tuple`]

Returns

ret – New array with the final dimension expanded, and the encodings stored in this channel.

ivy.function_supported_devices_and_dtypes(fn, recurse=True)[source]
Returns the supported combination of devices and dtypes

of the current backend’s function.

Parameters
• fn (`Callable`) – The function to check for the supported device and dtype attribute

• recurse – Whether to recurse into used ivy functions. Default is `True`.

Return type

`Dict`

Returns

ret – The unsupported devices of the function

ivy.function_unsupported_devices_and_dtypes(fn, recurse=True)[source]
Returns the unsupported combination of devices and dtypes

of the current backend’s function.

Parameters
• fn (`Callable`) – The function to check for the unsupported device and dtype attribute

• recurse – Whether to recurse into used ivy functions. Default is `True`.

Return type

`Dict`

Returns

ret – The unsupported combination of devices and dtypes of the function

ivy.gather(params, indices, /, *, axis=-1, batch_dims=0, out=None)[source]

Gather slices from params at axis according to indices.

Parameters
• params (`Union`[`Array`, `NativeArray`]) – The array from which to gather values.

• indices (`Union`[`Array`, `NativeArray`]) – The array which indicates the indices that will be gathered along the specified axis.

• axis (`Optional`[`int`]) – optional int, the axis from which to gather from. Default is `-1`. (default: `-1`)

• batch_dims (`Optional`[`int`]) – optional int, lets you gather different items from each element of a batch. (default: `0`)

• out (`Optional`[`Union`[`Array`, `NativeArray`]]) – optional array, for writing the result to. It must have a shape (default: `None`) that the inputs broadcast to.

Return type

`Union`[`Array`, `NativeArray`]

Returns

ret – New array with the values gathered at the specified indices along the specified axis.

Both the description and the type hints above assumes an array input for simplicity, but this function is nestable, and therefore also accepts `ivy.Container` instances in place of any of the arguments.

Examples

With `ivy.Array` input:

```>>> x = ivy.array([0., 1., 2.])
>>> y = ivy.array([1, 2])
>>> print(ivy.gather(x, y))
ivy.array([1., 2.])
```
```>>> x = ivy.array([[0., 1., 2.],[3., 4., 5.]])
>>> y = ivy.array([[0, 1],[1, 2]])
>>> z = ivy.array([[0., 0.],[0., 0.]])
>>> ivy.gather(x, y, out=z)
>>> print(z)
ivy.array([[[0., 1.],[1., 2.]],[[3., 4.],[4., 5.]]])
```
```>>> x = ivy.array([[[0., 1.], [2., 3.]],
...                [[8., 9.], [10., 11.]]])
>>> y = ivy.array([[0, 1]])
>>> ivy.gather(x, y, axis=0, out=x)
>>> print(x)
ivy.array(
[[[[ 0.,  1.],
[ 2.,  3.]],
[[ 8.,  9.],
[10., 11.]]]])
```
```>>> x = ivy.array([[0, 0, 1, 0, 2],
...                [3, 0, 0, 0, 4],
...                [0, 5, 0, 6, 0]])
>>> y = ivy.array([[1, 2],[3, 4],[5, 6]])
>>> z = ivy.gather(x, y, batch_dims=1)
>>> print(z)
ivy.array([[1, 2],[3, 4],[5, 6]])
```

With `ivy.Container` input:

```>>> x = ivy.Container(a = ivy.array([0., 1., 2.]),
...                   b = ivy.array([4., 5., 6.]))
>>> y = ivy.Container(a = ivy.array([0, 1]),
...                   b = ivy.array([1, 2]))
>>> print(ivy.gather(x, y))
{
a: ivy.array([0., 1.]),
b: ivy.array([5., 6.])
}
```

With a mix of `ivy.Array` and `ivy.Container` inputs:

```>>> x = ivy.Container(a = ivy.array([0., 1., 2.]),
...                   b = ivy.array([4., 5., 6.]))
>>> y = ivy.array([0, 1])
>>> print(ivy.gather(x, y))
{
a: ivy.array([0., 1.]),
b: ivy.array([4., 5.])
}
```
ivy.gather_nd(params, indices, /, *, batch_dims=0, out=None)[source]

Gather slices from params into a array with shape specified by indices.

Parameters
• params (`Union`[`Array`, `NativeArray`]) – The array from which to gather values.

• indices (`Union`[`Array`, `NativeArray`]) – Index array.

• out (`Optional`[`Array`]) – optional output array, for writing the result to. It must have a shape that the (default: `None`) inputs broadcast to.

Return type

`Array`

Returns

ret – New array of given shape, with the values gathered at the indices.

Examples

With `ivy.Array` input:

```>>> x = ivy.array([0., 1., 2., 3., 4., 5., 6.])
>>> y = ivy.array([1])
>>> print(ivy.gather_nd(x, y))
ivy.array(1.)
```
```>>> x = ivy.array([[0., 1.], [2., 3.], [4., 5.]])
>>> y = ivy.array([[0],[1],[1]], dtype='int32')
>>> z = ivy.gather_nd(x,y,batch_dims=1)
ivy.array([0., 3., 5.])
```

With a mix of `ivy.Array` and `ivy.Container` inputs:

```>>> x = ivy.Container(a=ivy.array([0., 1., 2.]),b=ivy.array([4., 5., 6.]))
>>> y = ivy.array([1])
>>> print(ivy.gather_nd(x, y))
{
a: ivy.array(1.),
b: ivy.array(5.)
}
```

With `ivy.Container` input:

```>>> x = ivy.Container(a=ivy.array([[0., 10., 20.],[30.,40.,50.]]),
...                   b=ivy.array([[0., 100., 200.],[300.,400.,500.]]))
>>> y = ivy.Container(a=ivy.array([1,0]),
...                   b=ivy.array([0]))
>>> print(ivy.gather_nd(x, y))
{
a: ivy.array(30.),
b: ivy.array([0., 100., 200.])
}
```
ivy.get_all_arrays_in_memory()[source]

Gets all arrays which are currently alive.

ivy.get_array_mode()[source]

Get the current state of array_mode

Examples

```>>> ivy.get_array_mode()
True
```
```>>> ivy.set_array_mode(False)
>>> ivy.get_array_mode()
False
```
Return type

`bool`

ivy.get_exception_trace_mode()[source]

Get the current state of exception_trace_mode

Examples

```>>> ivy.set_exception_trace_mode("full")
>>> ivy.get_exception_trace_mode()
'full'
```
Return type

`str`

ivy.get_item(x, query)[source]

Gather slices from x according to query array, identical to x[query].

Parameters
• x (`Union`[`Array`, `NativeArray`]) – array, the array from which to gather values.

• query (`Union`[`Array`, `NativeArray`]) – array, index array, integer indices or boolean mask.

Return type

`Array`

Returns

ret – New array with the values gathered at the specified indices.

Functional Examples

```>>> x = ivy.array([0, -1, 20])
>>> query = ivy.array([0, 1])
>>> print(ivy.get_item(x, query))
ivy.array([ 0, -1])
```
```>>> x = ivy.array([[4, 5], [20, 128], [-2, -10]])
>>> query = ivy.array([[True, False], [False, False], [True, True]])
>>> print(ivy.get_item(x, query))
ivy.array([  4,  -2, -10])
```
ivy.get_min_base()[source]

Gets the global minimum base used by ivy for numerically stable power raising.

Return type

`float`

Returns

ret – Global minimum base number

Examples

```>>> x = ivy.get_min_base()
>>> print(x)
1e-05
```
ivy.get_min_denominator()[source]

Get the global minimum denominator used by ivy for numerically stable division.

Return type

`float`

Returns

ret – A float number of the global minimum denominator.

Examples

```>>> x = ivy.get_min_denominator()
>>> print(x)
1e-12
```
ivy.get_nestable_mode()[source]

Get the current mode of whether to check if function inputs are ivy.Container. Default is `True`.

Examples

```>>> ivy.get_exception_trace_mode()
True
```
```>>> ivy.set_nestable_mode(False)
>>> ivy.get_exception_trace_mode()
False
```
Return type

`bool`

ivy.get_num_dims(x, /, *, as_array=False)[source]

Returns the number of dimensions of the array x.

Parameters
• x (`Union`[`Array`, `NativeArray`]) – Input array to infer the number of dimensions for.

• as_array (`bool`) – Whether to return the shape as a array, default False. (default: `False`)

Return type

`int`

Returns

• ret – Shape of the array

• Both the description and the type hints above assumes an array input for simplicity,

• but this function is nestable, and therefore also accepts `ivy.Container`

• instances in place of any of the arguments.

Examples

With `ivy.Array` input:

```>>> a = ivy.array([[[0, 0, 0], [0, 0, 0], [0, 0, 0]],
...                    [[0, 0, 0], [0, 0, 0], [0, 0, 0]],
...                    [[0, 0, 0], [0, 0, 0], [0, 0, 0]]])
>>> b = ivy.get_num_dims(a, as_array=False)
>>> print(b)
3
```

With `ivy.Container` input:

```>>> a = ivy.Container(b = ivy.asarray([[0.,1.,1.],[1.,0.,0.],[8.,2.,3.]]))
>>> ivy.get_num_dims(a)
2
```
```>>> b = ivy.get_num_dims(a, as_array=True)
>>> print(b)
ivy.array(3)
```
ivy.get_queue_timeout()[source]

Get the global queue timeout value (in seconds). The default value without this function being called is 15 seconds.

Return type

`float`

Returns

ret – The global queue timeout value (in seconds).

Examples

```>>> ivy.set_queue_timeout(10.0)
>>> y = ivy.get_queue_timeout()
>>> print(y)
10.0
```
ivy.get_referrers_recursive(item, depth=0, max_depth=None, seen_set=None, local_set=None)[source]

Summary.

Parameters
• item

• depth – (Default value = 0)

• max_depth – (Default value = None)

• seen_set – (Default value = None)

• local_set – (Default value = None`)

ivy.get_show_func_wrapper_trace_mode()[source]

Get the current state of whether to show the full stack trace with function wrapping traces. Default is True (function wrapping traces are shown)

Examples

```>>> ivy.get_show_func_wrapper_trace_mode()
True
```
```>>> ivy.set_show_func_wrapper_trace_mode(False)
>>> ivy.get_show_func_wrapper_trace_mode()
False
```
Return type

`bool`

ivy.get_tmp_dir()[source]

Get the path for directory that saves temporary files.

Returns

ret – The path of directory that saves temporary files.

ivy.has_nans(x, /, *, include_infs=True)[source]

Determine whether the array contains any nans, as well as infs or -infs if specified.

Parameters
• x (`Union`[`Array`, `NativeArray`]) – Input array.

• include_infs (`bool`) – Whether to include `+infinity` and `-infinity` in the check. (default: `True`) Default is `True`.

Return type

`bool`

Returns

ret – Boolean as to whether the array contains nans.

Both the description and the type hints above assumes an array input for simplicity, but this function is nestable, and therefore also accepts `ivy.Container` instances in place of any of the arguments.

Examples

With `ivy.Array` input:

```>>> x = ivy.array([1, 2, 3])
>>> y = ivy.has_nans(x)
>>> print(y)
False
```
```>>> x = ivy.array([float('nan'), 2, 3])
>>> y = ivy.has_nans(x)
>>> print(y)
True
```
```>>> x = ivy.array([float('inf'), 2, 3])
>>> y = ivy.has_nans(x)
>>> print(y)
True
```
```>>> x = ivy.array([float('inf'), 2, 3])
>>> y = ivy.has_nans(x, False)
>>> print(y)
False
```

With `ivy.Container` input:

```>>> x = ivy.Container(a=ivy.array([0., 1., 2.]), b=ivy.array([3., 4., 5.]))
>>> y = ivy.has_nans(x)
>>> print(y)
{
a: false,
b: false
}
```
ivy.inplace_arrays_supported(f=None)[source]

Determine whether inplace arrays are supported for the current backend framework.

Parameters

f – (Default value = None)

Returns

ret – Boolean, whether or not inplace arrays are supported.

ivy.inplace_decrement(x, val)[source]

Perform in-place decrement for the input array.

Parameters
• x (`Union`[`Array`, `NativeArray`]) – The input array to be decremented by the defined value.

• val (`Union`[`Array`, `NativeArray`]) – The value of decrement.

Return type

`Array`

Returns

ret – The array following the in-place decrement.

Both the description and the type hints above assumes an array input for simplicity, but this function is nestable, and therefore also accepts `ivy.Container` instances in place of any of the arguments.

Examples

With `ivy.Array` input:

```>>> x = ivy.array([[5.3, 7., 0.],[6.8, 8, 3.9],[0., 10., 6.3]])
>>> y = ivy.inplace_decrement(x, 1.25)
>>> print(y)
ivy.array([[ 4.05,  5.75, -1.25],
[ 5.55,  6.75,  2.65],
[-1.25,  8.75,  5.05]])
```

With `ivy.Container` input:

```>>> x = ivy.Container(a=ivy.array([0.5, -5., 30.]), b=ivy.array([0., -25., 50.]))
>>> y = ivy.inplace_decrement(x, 1.5)
>>> print(y)
{
a: ivy.array([-1., -6.5, 28.5]),
b: ivy.array([-1.5, -26.5, 48.5])
}
```
```>>> x = ivy.Container(a=ivy.array([0., 15., 30.]), b=ivy.array([0., 25., 50.]))
>>> y = ivy.Container(a=ivy.array([0., 15., 30.]), b=ivy.array([0., 25., 50.]))
>>> z = ivy.inplace_decrement(x, y)
>>> print(z)
{
a: ivy.array([0., 0., 0.]),
b: ivy.array([0., 0., 0.])
}
```
```>>> x = ivy.Container(a=ivy.array([3., 7., 10.]), b=ivy.array([0., 75., 5.5]))
>>> y = ivy.Container(a=ivy.array([2., 5.5, 7.]), b=ivy.array([0., 25., 2.]))
>>> z = ivy.inplace_decrement(x, y)
>>> print(z)
{
a: ivy.array([1., 1.5, 3.]),
b: ivy.array([0., 50., 3.5])
}
```
ivy.inplace_increment(x, val)[source]

Perform in-place increment for the input array.

Parameters
• x (`Union`[`Array`, `NativeArray`]) – The input array to be incremented by the defined value.

• val (`Union`[`Array`, `NativeArray`]) – The value of increment.

Return type

`Array`

Returns

ret – The array following the in-place increment.

Examples

With `ivy.Array` input:

```>>> x = ivy.array([[5.3, 7., 0.],[6.8, 8, 3.9],[0., 10., 6.3]])
>>> y = ivy.inplace_increment(x, 3.)
>>> print(y)
ivy.array([[ 8.3, 10.,  3.],
[ 9.8, 11.,  6.9],
[ 3., 13.,  9.3]])
```

With `ivy.Container` input:

```>>> x = ivy.Container(a=ivy.array([0., 15., 30.]), b=ivy.array([0., 25., 50.]))
>>> y = ivy.inplace_increment(x, 2.5)
>>> print(y)
{
a: ivy.array([2.5, 17.5, 32.5]),
b: ivy.array([2.5, 27.5, 52.5])
}
```
```>>> x = ivy.Container(a=ivy.array([0., 15., 30.]), b=ivy.array([0., 25., 50.]))
>>> y = ivy.Container(a=ivy.array([0., 15., 30.]), b=ivy.array([0., 25., 50.]))
>>> z = ivy.inplace_increment(x, y)
>>> print(z)
{
a: ivy.array([0., 30., 60.]),
b: ivy.array([0., 50., 100.])
}
```
ivy.inplace_update(x, val, ensure_in_backend=False)[source]

Perform in-place update for the input array. This will always be performed on ivy.Array instances pass in the input, and will also be performed on the native array classes in the backend when the backend supports this. If the backend does not natively support inplace updates, and x is an ivy.NativeArray instance, then an exception will be thrown.

Parameters
• x (`Union`[`Array`, `NativeArray`]) – The variable to update.

• val (`Union`[`Array`, `NativeArray`]) – The array to update the variable with.

• ensure_in_backend (`bool`) – Whether or not to ensure that the ivy.NativeArray is also inplace updated. (default: `False`) In cases where it should be, backends which do not natively support inplace updates will raise an exception.

Return type

`Array`

Returns

ret – The array following the in-place update.

ivy.inplace_variables_supported(f=None)[source]

Determine whether inplace variables are supported for the current backend framework.

Parameters

f – (Default value = None)

Returns

ret – Boolean, whether or not inplace variables are supported.

ivy.is_array(x, /, *, exclusive=False)[source]

Determines whether the input x is either an Ivy Array or a Native Array.

Parameters
• x (`Any`) – The input to check

• exclusive (`bool`) – Whether to check if the data type is exclusively an array, rather than a (default: `False`) variable or traced array.

Return type

`bool`

Returns

ret – Boolean, whether or not x is an array.

ivy.is_ivy_array(x, /, *, exclusive=False)[source]

Determines whether the input x is an Ivy Array.

Parameters
• x (`Union`[`Array`, `NativeArray`]) – The input to check

• exclusive (`Optional`[`bool`]) – Whether to check if the data type is exclusively an array, rather than a (default: `False`) variable or traced array.

Return type

`bool`

Returns

ret – Boolean, whether or not x is an array.

Examples

```>>> x = ivy.array([0, 1, 2])
>>> ivy.is_ivy_array(x)
True
```
```>>> x = ivy.native_array([9.1, -8.3, 2.8, 3.0])
>>> ivy.is_ivy_array(x, exclusive=True)
False
```
ivy.is_ivy_container(x, /)[source]

Determines whether the input x is an Ivy Container.

Parameters

x (`Any`) – The input to check

Return type

`bool`

Returns

ret – Boolean, whether or not x is an ivy container.

ivy.is_native_array(x, /, *, exclusive=False)[source]

Determines whether the input x is a Native Array.

Parameters
• x (`Union`[`Array`, `NativeArray`]) – The input to check

• exclusive (`bool`) – Whether to check if the data type is exclusively an array, rather than a (default: `False`) variable or traced array.

Return type

`bool`

Returns

ret – Boolean, whether or not x is a native array.

Examples

```>>> x = ivy.array([0, 1, 2])
>>> ivy.is_native_array(x)
False
```
```>>> x = ivy.native_array([9.1, -8.3, 2.8, 3.0])
>>> ivy.is_native_array(x, exclusive=True)
True
```
ivy.isscalar(x, /)[source]
Return type

`bool`

Match keyword arguments to either class or function receivers.

Parameters
• kwargs (`Dict`) – Keyword arguments to match.

• receivers (`Iterable`[`Callable`]) – Functions and/or classes to match the keyword arguments to.

• allow_duplicates (`bool`) – Whether to allow one keyword argument to be used for multiple receivers. (default: `False`) Default is `False`.

Return type

`Union`[`List`[`Dict`], `Dict`]

Returns

ret – Sequence of keyword arguments split as best as possible.

Examples

```>>> o = ivy.zeros(3)
>>> kwargs = {'out': o, 'bias': ivy.arange(3)}
>>> x = ivy.match_kwargs(kwargs, ivy.add, ivy.linear)
>>> print(x)
[{'out': ivy.array([0., 0., 0.])}, {'bias': ivy.array([0, 1, 2])}]
```
```>>> o = ivy.zeros(3)
>>> kwargs = {'out': o, 'bias': ivy.arange(3)}
>>> x = ivy.match_kwargs(kwargs, ivy.linear, ivy.add)
>>> print(x)
[{'out': ivy.array([0., 0., 0.]), 'bias': ivy.array([0, 1, 2])}, {}]
```
ivy.multiprocessing(context=None)[source]

Return backend-specific multiprocessing module.

Parameters

context (`Optional`[`str`]) – The context of the multiprocessing, either fork, forkserver or spawn. (default: `None`) Default is `None`.

Returns

ret – Multiprocessing module

ivy.num_arrays_in_memory()[source]

Returns the number of arrays which are currently alive.

ivy.print_all_arrays_in_memory()[source]

Gets all the native Ivy arrays which are currently alive(in the garbage collector) from get_all_arrays_in_memory() function and prints them to the console.

ivy.scatter_flat(indices, updates, /, *, size=None, reduction='sum', out=None)[source]

Scatter flat updates into a new flat array according to flat indices.

Parameters
• indices (`Union`[`Array`, `NativeArray`]) – Indices for the new values to occupy.

• updates (`Union`[`Array`, `NativeArray`]) – Values for the new array to hold.

• size (`Optional`[`int`]) – The size of the result. (default: `None`)

• reduction (`str`) – The reduction method for the scatter, one of ‘sum’, ‘min’, ‘max’ or ‘replace’ (default: `'sum'`)

• out (`Optional`[`Array`]) – optional output array, for writing the result to. It must have a shape that the (default: `None`) inputs broadcast to.

Return type

`Array`

Returns

ret – New array of given shape, with the values scattered at the indices.

ivy.scatter_nd(indices, updates, /, shape=None, *, reduction='sum', out=None)[source]

Scatter updates into a new array according to indices.

Parameters
• indices (`Union`[`Array`, `NativeArray`]) – Indices for the new values to occupy.

• updates (`Union`[`Array`, `NativeArray`]) – Values for the new array to hold.

• shape (`Optional`[`Union`[`Shape`, `NativeShape`]]) – The shape of the result. Default is `None`, in which case tensor (default: `None`) argument must be provided.

• reduction (`str`) – The reduction method for the scatter, one of ‘sum’, ‘min’, ‘max’ or ‘replace’ (default: `'sum'`)

• out (`Optional`[`Array`]) – optional output array, for writing the result to. It must have a shape that the (default: `None`) inputs broadcast to.

Return type

`Array`

Returns

ret – New array of given shape, with the values scattered at the indices.

Examples

scatter values into an empty array, With `ivy.Array` input:

```>>> indices = ivy.array([[4], [3], [1], [7]])
>>> updates = ivy.array([9, 10, 11, 12])
>>> shape = ivy.array([8])
>>> scatter = ivy.scatter_nd(indices, updates, shape)
>>> print(scatter)
ivy.array([ 0, 11,  0, 10,  9,  0,  0, 12])
```

scatter into an empty array, With `ivy.Container` input:

```>>> indices = ivy.Container(a=ivy.array([[4],[3],[6]]),
...                         b=ivy.array([[5],[1],[2]]))
>>> updates = ivy.Container(a=ivy.array([100, 200, 200]),
...                         b=ivy.array([20, 30, 40]))
>>> shape = ivy.Container(a=ivy.array([10]),
...                       b = ivy.array([10]))
>>> z = ivy.scatter_nd(indices, updates, shape=shape, reduction='replace')
>>> print(z)
{
a: ivy.array([0, 0, 0, 200, 100, 0, 200, 0, 0, 0]),
b: ivy.array([0, 30, 40, 0, 0, 20, 0, 0, 0, 0])
}
```

scatter into an array, With `ivy.Container` and `ivy.Array` input:

```>>> indices = ivy.array([[4],[3],[1]])
>>> updates = ivy.Container(a=ivy.array([10, 20, 30]),
...                         b=ivy.array([200, 300, 400]))
>>> z = ivy.Container(a=ivy.array([1, 2, 3, 4, 5]),
...                   b=ivy.array([10, 20, 30, 40, 50]))
>>> print(z)
{
a: ivy.array([1, 30, 3, 20, 10]),
b: ivy.array([10, 400, 30, 300, 200])
}
```
ivy.set_array_mode(mode)[source]

Set the mode of whether to convert inputs to ivy.NativeArray, then convert outputs back to ivy.Array

mode

boolean whether to perform ivy.Array conversions

Examples

```>>> ivy.set_array_mode(False)
>>> ivy.get_array_mode()
False
```
```>>> ivy.set_array_mode(True)
>>> ivy.get_array_mode()
True
```
Return type

`None`

ivy.set_exception_trace_mode(mode)[source]

Set the mode of whether to show frontend-truncated exception stack traces, ivy-truncated exception stack traces or full exception stack traces

mode

str exeption trace mode, one of ivy, full or frontend

Examples

```>>> ivy.set_exception_trace_mode("ivy")
>>> ivy.get_exception_trace_mode()
'ivy'
```
```>>> ivy.set_exception_trace_mode("full")
>>> ivy.get_exception_trace_mode()
'full'
```
Return type

`None`

ivy.set_min_base(val)[source]

Set the global minimum base used by ivy for numerically stable power raising.

Parameters

val (`float`) – The new value to set the minimum base to.

Examples

```>>> x = ivy.get_min_base()
>>> print(x)
1e-05
```

To set the minimum base to 1e-04

```>>> ivy.set_min_base(1e-04)
>>> y = ivy.get_min_base()
>>> print(y)
1e-04
```
Return type

`None`

ivy.set_min_denominator(val)[source]

Set the global minimum denominator used by ivy for numerically stable division.

Parameters

val (`float`) – The value to set the global minimum denominator to.

Examples

```>>> x = ivy.get_min_denominator()
>>> print(x)
1e-12
```

To set the minimum denominator to 1e-13

```>>> ivy.set_min_denominator(1e-13)
>>> y = ivy.get_min_denominator()
>>> print(y)
1e-13
```
Return type

`None`

ivy.set_nestable_mode(mode)[source]

Set the mode of whether to check if function inputs are ivy.Container

mode

boolean whether to check if function inputs are ivy.Container

Examples

```>>> ivy.set_nestable_mode(False)
>>> ivy.get_nestable_mode()
False
```
```>>> ivy.set_nestable_mode(True)
>>> ivy.get_nestable_mode()
True
```
Return type

`None`

ivy.set_queue_timeout(timeout)[source]

Set the global queue timeout value (in seconds) Default value without this function being called is 15 seconds.

Parameters

timeout (`float`) – The timeout when waiting for containers to arrive from the queues. To be set in seconds.

Examples

```>>> x = ivy.set_queue_timeout(10)
>>> x = ivy.get_queue_timeout()
>>> print(x)
10.0
```

To set the timeout for example 30 seconds

```>>> ivy.set_queue_timeout(30)
>>> y = ivy.get_queue_timeout()
>>> print(y)
30
```
ivy.set_shape_array_mode(mode)[source]

Set the mode of returning shape as ivy.Array to the given mode instance

mode

boolean whether to return shape as ivy.Array

Examples

```>>> ivy.set_shape_array_mode(False)
>>> ivy.shape_array_mode()
False
```
```>>> ivy.set_shape_array_mode(True)
>>> ivy.shape_array_mode()
True
```
Return type

`None`

ivy.set_show_func_wrapper_trace_mode(mode)[source]

Set the mode of whether to show the full stack trace with function wrapping traces

mode

boolean whether to perform ivy.Array conversions

Examples

```>>> ivy.set_show_func_wrapper_trace_mode(False)
>>> ivy.get_show_func_wrapper_trace_mode()
False
```
```>>> ivy.set_show_func_wrapper_trace_mode(True)
>>> ivy.get_show_func_wrapper_trace_mode()
True
```
Return type

`None`

ivy.set_tmp_dir(tmp_dr)[source]

Set the directory for saving temporary files.

Parameters

tmp_dr (`str`) – The new directory for saving temporary files

Examples

```>>> x = ivy.get_tmp_dir()
>>> print(x)
/tmp
```

To set the temp base to 1e-04

```>>> ivy.set_tmp_dir("/my_tmp")
>>> y = ivy.get_tmp_dir()
>>> print(y)
/my_tmp
```
Return type

`None`

ivy.shape(x, /, *, as_array=False)[source]

Returns the shape of the array `x`.

Parameters
• x (`Union`[`Array`, `NativeArray`]) – Input array to infer the shape of.

• as_array (`bool`) – Whether to return the shape as an array, default False. (default: `False`)

Return type

`Union`[`Shape`, `NativeShape`]

Returns

ret – Shape of the array `x`.

Examples

```>>> x = ivy.array([[-1, 0, 1],[1, 0, -1]])
>>> y = ivy.shape(x)
>>> z = ivy.shape(x, as_array = True)
>>> print(y)
(2, 3)
```
```>>> print(z)
ivy.array([2, 3])
```
ivy.shape_array_mode()[source]

Get the current state of shape_array_mode

Examples

```>>> ivy.shape_array_mode()
False
```
```>>> ivy.set_shape_array_mode(True)
>>> ivy.shape_array_mode()
True
```
Return type

`bool`

ivy.stable_divide(numerator, denominator, /, *, min_denominator=None)[source]

Divide the numerator by the denominator, with min denominator added to the denominator for numerical stability.

Parameters
• numerator (`Union`[`Number`, `Array`, `NativeArray`]) – The numerator of the division.

• denominator (`Union`[`Number`, `Array`, `NativeArray`]) – The denominator of the division.

• min_denominator (`Optional`[`Union`[`Number`, `Array`, `NativeArray`]]) – The minimum denominator to use, use global ivy._MIN_DENOMINATOR (1e-12) (default: `None`) by default.

Return type

`Union`[`Number`, `Array`]

Returns

ret – The new item following the numerically stable division.

Examples

With `int` input:

```>>> x = ivy.stable_divide(1, 2)
>>> print(x)
0.49999999999975
```
```>>> x = ivy.stable_divide(1, 4, min_denominator=1)
>>> print(x)
0.2
```

With float input:

```>>> x = ivy.stable_divide(5.0, 3.33)
>>> print(x)
1.5015015015010504
```

With `complex` input:

```>>> x = ivy.stable_divide(1+1j, 1-1j)
>>> print(x)
(5.000444502911705e-13+0.9999999999995j)
```

With `ivy.Array` input:

```>>> x = ivy.asarray([[10., 20., 30.],
...                  [40., 50., 60.]])
>>> y = ivy.stable_divide(x, 10.)
>>> print(y)
ivy.array([[1., 2., 3.],
[4., 5., 6.]])
```
```>>> x = ivy.asarray([1,2,3])
>>> y = np.array((1., 3., 5.))
>>> z = ivy.stable_divide(x, y)
>>> print(z)
ivy.array([1.   , 0.667, 0.6  ])
```
```>>> x = ivy.asarray([1., 2., 4.])
>>> y = ivy.asarray([1., 0.5, 0.25])
>>> z = ivy.asarray([0.01, 0.02, 0.03])
>>> w = ivy.stable_divide(x, y, min_denominator=z)
>>> print(w)
ivy.array([ 0.99,  3.85, 14.3 ])
```

With `ivy.Container` input:

```>>> x = ivy.Container(a=ivy.asarray([10., 15.]), b=ivy.asarray([20., 25.]))
>>> y = ivy.stable_divide(x, 0.5)
>>> print(y)
{
a: ivy.array([20., 30.]),
b: ivy.array([40., 50.])
}
```
```>>> x = ivy.Container(a=ivy.asarray([1., 2.]), b=ivy.asarray([3., 4.]))
>>> y = ivy.Container(a=ivy.asarray([0.5, 2.5]), b=ivy.asarray([3.5, 0.4]))
>>> z = ivy.stable_divide(x, y)
>>> print(z)
{
a: ivy.array([2., 0.8]),
b: ivy.array([0.857, 10.])
}
```
ivy.stable_pow(base, exponent, /, *, min_base=None)[source]

Raise the base by the power, with MIN_BASE added to the base when exponent > 1 for numerical stability.

Parameters
• base (`Union`[`Number`, `Array`, `NativeArray`]) – The base number.

• exponent (`Union`[`Number`, `Array`, `NativeArray`]) – The exponent number.

• min_base (`Optional`[`float`]) – The minimum base to use, use global ivy._MIN_BASE by default. (default: `None`)

Return type

`Any`

Returns

ret – The new item following the numerically stable power.

Determines whether in-place operations are supported for x’s data type, by the current backend framework setting.

Parameters

x (`Union`[`Array`, `NativeArray`]) – Input variable for whose data type we check whether the current backend framework supports in-place operations.

Return type

`bool`

Returns

ret – Value depends on whether in-place operations are supported for data type of x.

Raises
• ValueError – If x isn’t a class instance of ivy.Array or ivy.NativeArray, an exception will be raised.

• This function is nestable, and therefore also accepts :code:'ivy.Container'

• instance in place of the argument.

Examples

With `ivy.Array` input and default backend set as numpy:

```>>> x = ivy.array([0, 1, 2])
>>> print(y)
False
```

With `ivy.Container` input and backend set as torch:

```>>> x = ivy.Container(a=ivy.array([5., 6.]), b=ivy.array([7., 8.]))
>>> print(y)
{
a: false,
b: false
}
```
ivy.to_ivy_shape(shape)[source]

Returns the input shape in ivy.Shape form

Parameters

shape (`Union`[`Shape`, `NativeShape`]) – The input to be converted

Return type

`Shape`

Returns

ret – the input in ivy.Shape form

ivy.to_list(x, /)[source]

Creates a (possibly nested) list from input array.

Parameters

x (`Union`[`Array`, `NativeArray`]) – Input array.

Return type

`List`

Returns

ret – A list representation of the input array `x`.

Functional Examples

With `ivy.Array` input:

```>>> x = ivy.array([-1, 0, 1])
>>> y = ivy.to_list(x)
>>> print(y)
[-1, 0, 1]
```
```>>> x = ivy.array([[ 1.1,  2.2,  3.3],
...                [-4.4, -5.5, -6.6]])
>>> y = ivy.to_list(x)
>>> print(y)
[[1.100000023841858,2.200000047683716,3.299999952316284],
[-4.400000095367432,-5.5,-6.599999904632568]]
```
```>>> x = ivy.array([[[-1,  0,  1],
...                 [ 1,  0, -1]],
...                [[ 1, -1,  0],
...                 [ 1,  0, -1]]])
>>> y = ivy.to_list(x)
>>> print(y)
[[[-1, 0, 1], [1, 0, -1]], [[1, -1, 0], [1, 0, -1]]]
```

With a mix of `ivy.Container` and `ivy.Array` input:

```>>> x = ivy.Container(a=ivy.array([-1, 0, 1]))
>>> y = ivy.to_list(x)
>>> print(y)
{
a: [-1, 0, 1]
}
```
```>>> x = ivy.Container(a=ivy.array([[-1, 0, 1],
...                                [-1, 0, 1],
...                                [1, 0, -1]]))
>>> y = ivy.to_list(x)
>>> print(y)
{
a: [[-1, 0, 1], [-1, 0, 1], [1,0,-1]]
}
```
```>>> x =
... ivy.Container(a=ivy.array([[[-1, 0, 1],[1, 0, -1]],[[1, -1, 0],[1, 0, -1]]]))
>>> y = ivy.to_list(x)
>>> print(y)
{
a: [[[-1, 0, 1], [1, 0, -1]], [[1, -1, 0], [1, 0, -1]]]
}
```
ivy.to_native_shape(shape)[source]

Returns the input shape in its native backend framework form

Parameters

shape (`Union`[`Shape`, `NativeShape`]) – The input to be converted

Return type

`NativeShape`

Returns

ret – the input in its native framework form

ivy.to_numpy(x, /, *, copy=True)[source]

Converts an array into a numpy array.

Parameters
• x (`Union`[`Array`, `NativeArray`]) – input array

• copy (`bool`) – whether to copy the array to a new address or not. Default is `True`. (default: `True`)

Return type

/p>

Returns

ret – a numpy array copying all the element of the array `x`.

Examples

With `ivy.Array` inputs:

```>>> x = ivy.array([-1, 0, 1])
>>> y = ivy.to_numpy(x, copy=True)
>>> print(y)
[-1  0  1]
```
```>>> x = ivy.array([[-1, 0, 1],[-1, 0, 1], [1,0,-1]])
>>> y = ivy.to_numpy(x, copy=True)
>>> print(y)
[[-1  0  1]
[-1  0  1]
[ 1  0 -1]]
```

With `ivy.Container` input:

```>>> x = ivy.Container(a=ivy.array([-1, 0, 1]))
>>> y = ivy.to_numpy(x)
>>> print(y)
{
a: array([-1, 0, 1], dtype=int32)
}
```
```>>> x = ivy.Container(a=ivy.array([[-1.0, 0., 1.], [-1, 0, 1], [1, 0, -1]]),
...                   b=ivy.array([[-1, 0, 0], [1, 0, 1], [1, 1, 1]]))
>>> y = ivy.to_numpy(x)
>>> print(y)
{
a: array([[-1., 0., 1.],
[-1., 0., 1.],
[1., 0., -1.]], dtype=float32),
b: array([[-1, 0, 0],
[1, 0, 1],
[1, 1, 1]], dtype=int32)
}
```
ivy.to_scalar(x, /)[source]

Converts an array with a single element into a scalar.

Parameters

x (`Union`[`Array`, `NativeArray`]) – Input array with a single element.

Return type

`Number`

Returns

• ret – a scalar copying the element of the array `x`.

• Both the description and the type hints above assumes an array input for simplicity,

• but this function is nestable, and therefore also accepts `ivy.Container`

• instances in place of any of the arguments.

Functional Examples

With `ivy.Array` input:

```>>> x = ivy.array([3])
>>> y = ivy.to_scalar(x)
>>> print(y)
3
```

With a mix of `ivy.Container` and `ivy.Array` input:

```>>> x = ivy.Container(a=ivy.array([-1]), b=ivy.array([3]))
>>> y = ivy.to_scalar(x)
>>> print(y)
{
a: -1,
b: 3
}
```
```>>> x = ivy.Container(a=ivy.array([1]), b=ivy.array([0]),
...                   c=ivy.array([-1]))
>>> y = ivy.to_scalar(x)
>>> print(y)
{
a: 1,
b: 0,
c: -1
}
```
ivy.try_else_none(fn, *args, **kwargs)[source]
Try and return the function, otherwise return None

if an exception was raised during function execution.

Parameters
• fn (`Callable`) – Function to try and call and return.

• args (`Any`) – list of arguments.

• kwargs (`Any`) – dictionay of keyword arguments

Return type

`Optional`[`Callable`]

Returns

• Either the function itself or None if an exception was raised

• during function execution.

Examples

with: if the function is executed without any exception:

```>>> x = ivy.array([1, 2, 3])
>>> y = ivy.array([4, 5, 6])
>>> print(z.__name__)
```

with: if the function is executed with an exception:

```>>> x = ivy.array([1, 2, 3])
>>> y = 'hemant'
>>> print(z)
None
```
ivy.unset_array_mode()[source]

Reset the mode of converting inputs to ivy.NativeArray, then converting outputs back to ivy.Array to the previous state

Examples

```>>> ivy.set_array_mode(False)
>>> ivy.get_array_mode()
False
```
```>>> ivy.unset_shape_array_mode()
>>> ivy.get_array_mode()
True
```
Return type

`None`

ivy.unset_exception_trace_mode()[source]

Reset the trace mode to the previously set mode

Examples

```>>> ivy.set_exception_trace_mode("ivy")
>>> ivy.get_exception_trace_mode()
'ivy'
```
```>>> ivy.unset_exception_trace_mode()
>>> ivy.get_exception_trace_mode()
'full'
```
Return type

`None`

ivy.unset_nestable_mode()[source]

Reset the mode of whether to check if function inputs are ivy.Container to the previous state

Examples

```>>> ivy.set_nestable_mode(False)
>>> ivy.get_nestable_mode()
False
```
```>>> ivy.unset_nestable_mode()
>>> ivy.get_nestable_mode()
True
```
Return type

`None`

ivy.unset_queue_timeout()[source]

Reset the global queue timeout value (in seconds) to the previous state

Examples

```>>> ivy.set_queue_timeout(10.0)
>>> y = ivy.get_queue_timeout()
>>> print(y)
10.0
```
```>>> ivy.unset_shape_array_mode()
>>> ivy.get_queue_timeout()
15.0
```
Return type

`None`

ivy.unset_shape_array_mode()[source]

Reset the mode of returning shape as ivy.Array to the previous state

Examples

```>>> ivy.set_shape_array_mode(True)
>>> ivy.shape_array_mode()
True
```
```>>> ivy.unset_shape_array_mode()
>>> ivy.shape_array_mode()
False
```
Return type

`None`

ivy.unset_show_func_wrapper_trace_mode()[source]

Reset the mode of whether to show the full stack trace with function wrapping traces

Examples

```>>> ivy.set_show_func_wrapper_trace_mode(False)
>>> ivy.get_show_func_wrapper_trace_mode()
False
```
```>>> ivy.unset_show_func_wrapper_trace_mode()
>>> ivy.get_show_func_wrapper_trace_mode()
True
```
Return type

`None`

ivy.value_is_nan(x, /, *, include_infs=True)[source]

Determines whether the single valued array or scalar is of nan type.

Parameters
• x (`Union`[`Array`, `NativeArray`, `Number`]) – The input to check Input array.

• include_infs (`Optional`[`bool`]) – Whether to include infs and -infs in the check. Default is `True`. (default: `True`)

Return type

`bool`

Returns

ret – Boolean as to whether the input value is a nan or not.

Examples

```>>> x = ivy.array([451])
>>> y = ivy.value_is_nan(x)
>>> print(y)
False
```
```>>> x = ivy.array([float('inf')])
>>> y = ivy.value_is_nan(x)
>>> print(y)
True
```
```>>> x = ivy.array([float('inf')])
>>> y = ivy.value_is_nan(x, include_infs=False)
>>> print(y)
False
```
```>>> x = ivy.array([float('nan')])
>>> y = ivy.value_is_nan(x, include_infs=False)
>>> print(y)
True
```
```>>> x = ivy.array([0])
>>> y = ivy.value_is_nan(x)
>>> print(y)
False
```
ivy.vmap(func, in_axes=0, out_axes=0)[source]

Vectorizing map. Creates a function which maps func over argument axes.

Parameters
• func (`Callable`) – Function to be mapped over additional axes.

• in_axes (`Union`[`int`, `Sequence`[`int`], `Sequence`[`None`]]) – An integer, None, or (nested) standard Python container (default: `0`) (tuple/list) thereof specifying which input array axes to map over.If each positional argument to fun is an array, then in_axes can be an integer, a None, or a tuple of integers and Nones with length equal to the number of positional arguments to fun. An integer or None indicates which array axis to map over for all arguments (with None indicating not to map any axis), and a tuple indicates which axis to map for each corresponding positional argument. Axis integers must be in the range [-ndim, ndim) for each array, where ndim is the number of dimensions (axes) of the corresponding input array.

• out_axes (`Optional`[`int`]) – An integer indicating where the mapped axis should appear in the output. (default: `0`)

Return type

`Callable`

Returns

ret – Batched/vectorized version of func with arguments that correspond to those of func, but with extra array axes at positions indicated by in_axes, and a return value that corresponds to that of fun, but with extra array axes at positions indicated by out_axes.

This docstring is a summarised version of the docstring for vmap from JAX documentation.

Examples

With `ivy.matmul()` and `ivy.Array` input:

```>>> x = ivy.array(ivy.arange(60).reshape((3, 5, 4)))
>>> y = ivy.array(ivy.arange(40).reshape((5, 4, 2)))
>>> z = ivy.vmap(ivy.matmul, (1, 0), 1)(x, y)
>>> print(z.shape)
(3, 5, 2)
```

This should have hopefully given you an overview of the general submodule,If you have any questions, please feel free to reach out on our discord in the general channel or in the general forum!