id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
146,388 | from typing import Callable, TypeVar
from returns.interfaces.bindable import BindableN
from returns.primitives.hkt import Kinded, KindN, kinded
_FirstType = TypeVar('_FirstType')
_SecondType = TypeVar('_SecondType')
_ThirdType = TypeVar('_ThirdType')
_UpdatedType = TypeVar('_UpdatedType')
_BindableKind = TypeVar('_Bind... | Turns function's input parameter from a regular value to a container. In other words, it modifies the function signature from: ``a -> Container[b]`` to: ``Container[a] -> Container[b]`` Similar to :func:`returns.pointfree.lash`, but works for successful containers. This is how it should be used: .. code:: python >>> fr... |
146,389 | from typing import Callable, TypeVar
from returns.interfaces.specific.reader import ReaderLike2, ReaderLike3
from returns.primitives.hkt import Kind2, Kind3, Kinded, kinded
_FirstType = TypeVar('_FirstType')
_SecondType = TypeVar('_SecondType')
_UpdatedType = TypeVar('_UpdatedType')
_Reader2Kind = TypeVar('_Reader2Kind... | Modifies the second type argument of a ``ReaderLike2``. In other words, it modifies the function's signature from: ``a -> b`` to: ``Container[x, a] -> Container[x, b]`` .. code:: python >>> from returns.pointfree import modify_env2 >>> from returns.context import RequiresContext >>> def multiply(arg: int) -> RequiresCo... |
146,390 | from typing import Callable, TypeVar
from returns.interfaces.specific.reader import ReaderLike2, ReaderLike3
from returns.primitives.hkt import Kind2, Kind3, Kinded, kinded
_FirstType = TypeVar('_FirstType')
_SecondType = TypeVar('_SecondType')
_ThirdType = TypeVar('_ThirdType')
_UpdatedType = TypeVar('_UpdatedType')
_... | Modifies the third type argument of a ``ReaderLike3``. In other words, it modifies the function's signature from: ``a -> b`` to: ``Container[x, a] -> Container[x, b]`` .. code:: python >>> from returns.pointfree import modify_env >>> from returns.context import RequiresContextResultE >>> from returns.result import Succ... |
146,391 | from abc import ABCMeta
from functools import wraps
from typing import (
TYPE_CHECKING,
Any,
Callable,
ClassVar,
Generator,
Iterator,
NoReturn,
Optional,
TypeVar,
Union,
final,
)
from typing_extensions import ParamSpec
from returns.interfaces.specific.maybe import MaybeBased2... | Decorator to convert ``None``-returning function to ``Maybe`` container. This decorator works with sync functions only. Example: .. code:: python >>> from typing import Optional >>> from returns.maybe import Nothing, Some, maybe >>> @maybe ... def might_be_none(arg: int) -> Optional[int]: ... if arg == 0: ... return No... |
146,392 | from functools import wraps
from typing import (
Any,
AsyncGenerator,
AsyncIterator,
Awaitable,
Callable,
Coroutine,
Generator,
TypeVar,
final,
)
from typing_extensions import ParamSpec
from returns._internal.futures import _future, _future_result
from returns.interfaces.specific.fut... | Async function that returns its argument. .. code:: python >>> import anyio >>> from returns.future import async_identity >>> assert anyio.run(async_identity, 1) == 1 See :func:`returns.functions.identity` for sync version of this function and more docs and examples. |
146,393 | from functools import wraps
from typing import (
Any,
AsyncGenerator,
AsyncIterator,
Awaitable,
Callable,
Coroutine,
Generator,
TypeVar,
final,
)
from typing_extensions import ParamSpec
from returns._internal.futures import _future, _future_result
from returns.interfaces.specific.fut... | Decorator to turn a coroutine definition into ``Future`` container. .. code:: python >>> import anyio >>> from returns.io import IO >>> from returns.future import future >>> @future ... async def test(x: int) -> int: ... return x + 1 >>> assert anyio.run(test(1).awaitable) == IO(2) |
146,394 | from functools import wraps
from typing import (
Any,
AsyncGenerator,
AsyncIterator,
Awaitable,
Callable,
Coroutine,
Generator,
TypeVar,
final,
)
from typing_extensions import ParamSpec
from returns._internal.futures import _future, _future_result
from returns.interfaces.specific.fut... | Decorator to turn a common function into an asynchronous function. This decorator is useful for composition with ``Future`` and ``FutureResult`` containers. .. warning:: This function will not your sync function **run** like async one. It will still be a blocking function that looks like async one. We recommend to only... |
146,395 | from functools import wraps
from typing import (
Any,
AsyncGenerator,
AsyncIterator,
Awaitable,
Callable,
Coroutine,
Generator,
TypeVar,
final,
)
from typing_extensions import ParamSpec
from returns._internal.futures import _future, _future_result
from returns.interfaces.specific.fut... | Public unit function to create successful ``FutureResult`` objects. Is the same as :meth:`~FutureResult.from_value`. .. code:: python >>> import anyio >>> from returns.future import FutureResult, FutureSuccess >>> assert anyio.run(FutureSuccess(1).awaitable) == anyio.run( ... FutureResult.from_value(1).awaitable, ... ) |
146,396 | from functools import wraps
from typing import (
Any,
AsyncGenerator,
AsyncIterator,
Awaitable,
Callable,
Coroutine,
Generator,
TypeVar,
final,
)
from typing_extensions import ParamSpec
from returns._internal.futures import _future, _future_result
from returns.interfaces.specific.fut... | Public unit function to create failed ``FutureResult`` objects. Is the same as :meth:`~FutureResult.from_failure`. .. code:: python >>> import anyio >>> from returns.future import FutureResult, FutureFailure >>> assert anyio.run(FutureFailure(1).awaitable) == anyio.run( ... FutureResult.from_failure(1).awaitable, ... ) |
146,397 | from functools import wraps
from typing import (
Any,
AsyncGenerator,
AsyncIterator,
Awaitable,
Callable,
Coroutine,
Generator,
TypeVar,
final,
)
from typing_extensions import ParamSpec
from returns._internal.futures import _future, _future_result
from returns.interfaces.specific.fut... | Decorator to convert exception-throwing coroutine to ``FutureResult``. Should be used with care, since it only catches ``Exception`` subclasses. It does not catch ``BaseException`` subclasses. If you need to mark sync function as ``safe``, use :func:`returns.future.future_safe` instead. This decorator only works with `... |
146,398 | from abc import ABCMeta
from functools import wraps
from inspect import FrameInfo
from typing import (
TYPE_CHECKING,
Any,
Callable,
Generator,
Iterator,
List,
Optional,
TypeVar,
Union,
final,
)
from typing_extensions import ParamSpec
from returns.interfaces.specific import io, i... | Decorator to mark function that it returns :class:`~IO` container. If you need to mark ``async`` function as impure, use :func:`returns.future.future` instead. This decorator only works with sync functions. Example: .. code:: python >>> from returns.io import IO, impure >>> @impure ... def function(arg: int) -> int: ..... |
146,399 | from abc import ABCMeta
from functools import wraps
from inspect import FrameInfo
from typing import (
TYPE_CHECKING,
Any,
Callable,
Generator,
Iterator,
List,
Optional,
TypeVar,
Union,
final,
)
from typing_extensions import ParamSpec
from returns.interfaces.specific import io, i... | Decorator to mark function that it returns :class:`~IOResult` container. Should be used with care, since it only catches ``Exception`` subclasses. It does not catch ``BaseException`` subclasses. If you need to mark ``async`` function as impure, use :func:`returns.future.future_safe` instead. This decorator only works w... |
146,400 | from typing import TypeVar
from returns.io import IO
_ValueType = TypeVar('_ValueType')
class IO( # type: ignore[type-var]
BaseContainer,
SupportsKind1['IO', _ValueType],
io.IOLike1[_ValueType],
):
"""
Explicit container for impure function results.
We also sometimes call it "marker" since on... | Compatibility utility and escape mechanism from ``IO`` world. Just unwraps the internal value from :class:`returns.io.IO` container. Should be used with caution! Since it might be overused by lazy and ignorant developers. It is recommended to have only one place (module / file) in your program where you allow unsafe op... |
146,401 | import os
import sys
import webbrowser
from platform import system
from traceback import print_exc
from typing import Callable
from typing import List
from typing import Tuple
def clear_screen():
os.system("cls" if system() == "Windows" else "clear") | null |
146,402 | import os
import sys
import webbrowser
from platform import system
from traceback import print_exc
from typing import Callable
from typing import List
from typing import Tuple
def validate_input(ip, val_range):
val_range = val_range or []
try:
ip = int(ip)
if ip in val_range:
return... | null |
146,403 | import re
from core import HackingTool
from core import HackingToolsCollection
from hackingtool import all_tools
def get_toc(tools, indentation = ""):
def get_tools_toc(tools, indentation = "##"):
all_tools = [
AnonSurfTools(),
InformationGatheringTools(),
WordlistGeneratorTools(),
WirelessAttackTools(... | null |
146,404 | import setuptools
from setuptools import setup
from pathlib import Path
from urllib import request
import os
import json
import re
The provided code snippet includes necessary dependencies for implementing the `_get_paths_from_binaries` function. Write a Python function `def _get_paths_from_binaries(binaries, root_dir... | Get all the paths from the binaries.json into a list. |
146,405 | import setuptools
from setuptools import setup
from pathlib import Path
from urllib import request
import os
import json
import re
def _strip(line):
return line.split(" ")[0].split("#")[0].split(",")[0] | null |
146,406 | import ivy
from typing import Callable, Type, List, Iterable, Optional, Union, Sequence, Dict
from types import ModuleType
TO_IGNORE = ["is_ivy_array", "is_native_array", "is_array", "shape"]
def _wrap_function(function_name: str, static: bool) -> Callable:
"""Wrap the function called `function_name`.
Parameter... | Loop over all ivy modules such as activations, general, etc. and add the module functions to ivy container as instance methods using _wrap_function. Parameters ---------- cls the class we want to add the instance methods to. modules the modules to loop over: activations, general etc. static whether the function should ... |
146,407 | import inspect
from itertools import chain
import re
import abc
import copy
import termcolor
import numpy as np
import json
from ivy.utils.exceptions import IvyBackendException, IvyException
import pickle
import random
from operator import mul
from functools import reduce as _reduce
from typing import Union, Tuple
from... | null |
146,408 | import inspect
from itertools import chain
import re
import abc
import copy
import termcolor
import numpy as np
import json
from ivy.utils.exceptions import IvyBackendException, IvyException
import pickle
import random
from operator import mul
from functools import reduce as _reduce
from typing import Union, Tuple
from... | null |
146,409 | from typing import (
Optional,
Union,
List,
Dict,
Sequence,
Tuple,
Literal,
Any,
Callable,
Iterable,
)
from numbers import Number
import ivy
from ivy.data_classes.container.base import ContainerBase
The provided code snippet includes necessary dependencies for implementing the `... | ivy.Container instance method variant of ivy.stack. This method simply wraps the function, and so the docstring for ivy.stack also applies to this method with minimal changes. Parameters ---------- self Container with leaves to join with leaves of other arrays/containers. Each array leave must have the same shape. inpu... |
146,410 | from .base import FactorizedTensor
import ivy
from copy import deepcopy
import warnings
def _bisection_root_finder(fun, a, b, tol=1e-6, max_iter=100):
if fun(a) * fun(b) >= 0:
raise ValueError(
"Function values at the interval endpoints must have opposite signs"
)
for _ in range(ma... | null |
146,411 | import ivy
from typing import Callable, Type, List, Iterable
from types import ModuleType
TO_IGNORE = ["shape"]
def _wrap_function(function_name: str) -> Callable:
"""Wrap the function called `function_name`.
Parameters
----------
function_name
the name of the function e.g. "abs", "mean" etc.
... | Loop over all ivy modules such as activations, general, etc. and add the module functions to ivy arrays as instance methods using _wrap_function. Parameters ---------- cls the class we want to add the instance methods to. modules the modules to loop over: activations, general etc. to_ignore any items we don't want to a... |
146,412 | import numpy as np
from typing import Any, Union, Tuple, Dict, Iterable, Optional
import ivy
def _to_ivy(x: Any) -> Any:
if isinstance(x, ivy.Array):
return x
elif isinstance(x, ivy.NativeShape):
return ivy.Shape(x)
elif isinstance(x, ivy.Container):
return x.to_ivy()
if ivy.is_n... | Return args and keyword args in their ivy.Array or form for all nested instances, otherwise the arguments are returned unchanged. Parameters ---------- args The positional arguments to check include_derived Whether to also recursive for classes derived from tuple, list and dict. Default is ``False``. kwargs The key-wor... |
146,413 | import numpy as np
from typing import Any, Union, Tuple, Dict, Iterable, Optional
import ivy
def _to_native(x: Any, inplace: bool = False, to_ignore: tuple = ()) -> Any:
to_ignore = ivy.default(to_ignore, ())
if isinstance(x, to_ignore):
return x
if isinstance(x, ivy.Array):
return x.data
... | Return the input item in its native backend framework form if it is an ivy.Array instance, otherwise the input is returned unchanged. If nested is set, the check is applied to all nested leaves of tuples, lists and dicts contained within ``x``. Parameters ---------- x The input to maybe convert. nested Whether to apply... |
146,414 | import numpy as np
from typing import Any, Union, Tuple, Dict, Iterable, Optional
import ivy
def _to_native(x: Any, inplace: bool = False, to_ignore: tuple = ()) -> Any:
to_ignore = ivy.default(to_ignore, ())
if isinstance(x, to_ignore):
return x
if isinstance(x, ivy.Array):
return x.data
... | Return args and keyword args in their native backend framework form for all nested ivy.Array instances, otherwise the arguments are returned unchanged. Parameters ---------- args The positional arguments to check include_derived Whether to also recursive for classes derived from tuple, list and dict. Default is ``False... |
146,415 | import numpy as np
from typing import Any, Union, Tuple, Dict, Iterable, Optional
import ivy
def _to_new_backend(
x: Any,
native: bool = False,
inplace: bool = False,
to_ignore: tuple = (),
) -> Any:
if isinstance(x, ivy.Container):
to_ignore = ivy.default(to_ignore, ())
return x.con... | Return the input array converted to new backend framework form if it is an `ivy.Array`, `ivy.NativeArray` or NativeVariable instance. If nested is set, the check is applied to all nested leaves of tuples, lists and dicts contained within ``x``. Parameters ---------- x The input to maybe convert. native Whether to retur... |
146,416 | import numpy as np
from typing import Any, Union, Tuple, Dict, Iterable, Optional
import ivy
def _to_new_backend(
x: Any,
native: bool = False,
inplace: bool = False,
to_ignore: tuple = (),
) -> Any:
if isinstance(x, ivy.Container):
to_ignore = ivy.default(to_ignore, ())
return x.con... | Return args and keyword args in the new current backend framework for all nested ivy.Array, ivy.NativeArray or NativeVariable instances. Parameters ---------- args The positional arguments to check native Whether to return the new array as a ivy.NativeArray, NativeVariable or an ivy.Array. Default is ``True``. include_... |
146,417 | import abc
from typing import Optional, Union
import ivy
The provided code snippet includes necessary dependencies for implementing the `polyval` function. Write a Python function `def polyval( coeffs=ivy.Array, x=Union[ivy.Array, ivy.NativeArray, int, float], /, *, dtype: Optional[Union[ivy.Dtype,... | ivy.Array instance method of polyval. This method simply wraps the function, and so the docstring for ivy.polyval also applies to this method with minimal changes. Evaluate and return a polynomial at specific given values. Parameters ---------- coeffs Input array containing polynomial coefficients (including zero) from... |
146,418 | import contextlib
import ivy
import functools
import logging
import weakref
import warnings
import copy as python_copy
from types import FunctionType
from typing import Callable, Literal
import inspect
import numpy as np
from ivy.utils.exceptions import IvyValueError
def try_array_function_override(func, overloaded_arg... | Wrap a function `fn` to be passed to array_function method. Wrap a function to extract the relevant argument types to be passed to array_function method. |
146,419 | import contextlib
import ivy
import functools
import logging
import weakref
import warnings
import copy as python_copy
from types import FunctionType
from typing import Callable, Literal
import inspect
import numpy as np
from ivy.utils.exceptions import IvyValueError
def inputs_to_native_shapes(fn: Callable) -> Callabl... | Make `fn` receive `ivy.NativeShape` and return `ivy.Shape`. Wrap `fn` so that input shapes are all converted to `ivy.NativeShape` instances and return shapes are all converted to `ivy.Shape` instances. |
146,420 | import contextlib
import ivy
import functools
import logging
import weakref
import warnings
import copy as python_copy
from types import FunctionType
from typing import Callable, Literal
import inspect
import numpy as np
from ivy.utils.exceptions import IvyValueError
def _build_view(original, view, fn, args, kwargs, in... | Wrap `fn` and performs view handling if copy is False. Used for functional backends (Jax and TensorFlow). Checks if the first arg is a view or original array by checking if the ._base attribute is populated. If it's original it adds the returned array to its view references, then the returned array adds the operation t... |
146,421 | import contextlib
import ivy
import functools
import logging
import weakref
import warnings
import copy as python_copy
from types import FunctionType
from typing import Callable, Literal
import inspect
import numpy as np
from ivy.utils.exceptions import IvyValueError
def _build_view(original, view, fn, args, kwargs, in... | Wrap `fn` and performs view handling specifically for indexing. As with NumPy it returns a copy if advanced indexing is performed. Used for functional backends (Jax and TensorFlow). Checks if the first arg is a view or original array by checking if the ._base attribute is populated. If it's original it adds the returne... |
146,422 | import contextlib
import ivy
import functools
import logging
import weakref
import warnings
import copy as python_copy
from types import FunctionType
from typing import Callable, Literal
import inspect
import numpy as np
from ivy.utils.exceptions import IvyValueError
def _convert_numpy_arrays_to_backend_specific(*args)... | Wrap `fn` and converts all `numpy.ndarray` inputs to `torch.Tensor` instances. Used for functional backends (PyTorch). Converts all `numpy.ndarray` inputs to `torch.Tensor` instances. |
146,423 | import contextlib
import ivy
import functools
import logging
import weakref
import warnings
import copy as python_copy
from types import FunctionType
from typing import Callable, Literal
import inspect
import numpy as np
from ivy.utils.exceptions import IvyValueError
import ivy.utils.backend.handler
from ivy.utils imp... | null |
146,424 | import contextlib
import ivy
import functools
import logging
import weakref
import warnings
import copy as python_copy
from types import FunctionType
from typing import Callable, Literal
import inspect
import numpy as np
from ivy.utils.exceptions import IvyValueError
def _update_torch_views(x, visited_view=None):
impo... | null |
146,425 | import contextlib
import ivy
import functools
import logging
import weakref
import warnings
import copy as python_copy
from types import FunctionType
from typing import Callable, Literal
import inspect
import numpy as np
from ivy.utils.exceptions import IvyValueError
import ivy.utils.backend.handler
from ivy.utils imp... | null |
146,426 | import contextlib
import ivy
import functools
import logging
import weakref
import warnings
import copy as python_copy
from types import FunctionType
from typing import Callable, Literal
import inspect
import numpy as np
from ivy.utils.exceptions import IvyValueError
import ivy.utils.backend.handler
from ivy.utils imp... | null |
146,427 | import contextlib
import ivy
import functools
import logging
import weakref
import warnings
import copy as python_copy
from types import FunctionType
from typing import Callable, Literal
import inspect
import numpy as np
from ivy.utils.exceptions import IvyValueError
def casting_modes_ops(fn, ret_dtype_target=None):
... | Create a wrapper for a dtype or device attribute. The wrapper returns the correct dtype or device for the current version of the backend. Parameters ---------- attrib The attribute name to be wrapped. for example, "unsupported_dtypes" t The type of the attribute. for example, "tuple" Returns ------- A wrapper function ... |
146,428 | import contextlib
import ivy
import functools
import logging
import weakref
import warnings
import copy as python_copy
from types import FunctionType
from typing import Callable, Literal
import inspect
import numpy as np
from ivy.utils.exceptions import IvyValueError
def _nest_has_nans(x):
return ivy.nested_any(x, ... | null |
146,429 | import contextlib
import ivy
import functools
import logging
import weakref
import warnings
import copy as python_copy
from types import FunctionType
from typing import Callable, Literal
import inspect
import numpy as np
from ivy.utils.exceptions import IvyValueError
import ivy.utils.backend.handler
from ivy.utils imp... | null |
146,430 | import contextlib
import ivy
import functools
import logging
import weakref
import warnings
import copy as python_copy
from types import FunctionType
from typing import Callable, Literal
import inspect
import numpy as np
from ivy.utils.exceptions import IvyValueError
import ivy.utils.backend.handler
from ivy.utils imp... | null |
146,431 | import contextlib
import ivy
import functools
import logging
import weakref
import warnings
import copy as python_copy
from types import FunctionType
from typing import Callable, Literal
import inspect
import numpy as np
from ivy.utils.exceptions import IvyValueError
def globals_getter_func(x=None):
# define and a... | null |
146,432 | import ast
import astunparse
import inspect
replace_map = {}
The provided code snippet includes necessary dependencies for implementing the `replace_with` function. Write a Python function `def replace_with(new_func)` to solve the following problem:
Decorate a function/method/attribute to be replaced by another. Param... | Decorate a function/method/attribute to be replaced by another. Parameters ---------- new_func The function that will replace the original. |
146,433 | import ast
import astunparse
import inspect
class ReplaceFunction(ast.NodeTransformer):
"""AST Node Transformer to replace function calls, methods, and
attributes."""
def visit_Attribute(self, node):
if (
isinstance(node.value, ast.Name)
and f"{node.value.id}.{node.attr}" in ... | Transform the function by replacing its calls based on the replace_map. |
146,434 | from typing import Callable, Optional, List, Union, Iterable, Sequence, Mapping
The provided code snippet includes necessary dependencies for implementing the `trace_graph` function. Write a Python function `def trace_graph( *objs: Callable, stateful: Optional[List] = None, arg_stateful_idxs: Optional[List... | Takes `fn` and traces it into a more efficient composition of backend operations. Parameters ---------- objs callable(s) to trace and create a graph of stateful list of instances to be considered stateful during the graph tracing arg_stateful_idxs positional arguments to be considered stateful during the graph tracing ... |
146,435 | from typing import Callable, Optional, List, Union, Iterable, Sequence, Mapping
The provided code snippet includes necessary dependencies for implementing the `transpile` function. Write a Python function `def transpile( *objs: Callable, source: Optional[str] = None, to: Optional[str] = None, with_nump... | Transpiles Callable objects passed as arguments. If args and kwargs are specified, transpilation is performed eagerly, otherwise, transpilation will happen lazily. Parameters ---------- objs The native Callables to be transpiled source The framework that `obj` is from. to The target framework to transpile `obj` to. arg... |
146,436 | from typing import Callable, Optional, List, Union, Iterable, Sequence, Mapping
def unify(
*objs: Callable,
source: Optional[str] = None,
graph_caching: bool = False,
graph_optimizations: bool = True,
args: Optional[Sequence] = None,
kwargs: Optional[Mapping] = None,
with_numpy: bool = True... | null |
146,437 | import os
import logging
import json
from urllib import request
import importlib
import ivy
if os.path.exists(wrappers_path):
wrappers = json.loads(open(wrappers_path).read())
wrapers_dir = os.path.join(folder_path, "ivy/wrappers")
The provided code snippet includes necessary dependencies for implementing the `dow... | Get the wrapper for the given function name. |
146,438 | import os
import logging
import json
from urllib import request
import importlib
import ivy
The provided code snippet includes necessary dependencies for implementing the `wrapper_exists` function. Write a Python function `def wrapper_exists(func_name: str)` to solve the following problem:
Check if the wrapper for the... | Check if the wrapper for the given function name exists. |
146,439 | import os
import logging
import json
from urllib import request
import importlib
import ivy
if os.path.exists(wrappers_path):
wrappers = json.loads(open(wrappers_path).read())
The provided code snippet includes necessary dependencies for implementing the `load_one_wrapper` function. Write a Python function `def lo... | Load the wrapper for the given function name. |
146,440 | import functools
from typing import Optional, Dict, List
import re
import inspect
import ivy
from ivy.utils.backend import current_backend
The provided code snippet includes necessary dependencies for implementing the `to_ivy_module` function. Write a Python function `def to_ivy_module( native_module=None, na... | Convert an instance of a trainable module from a native framework into a trainable ivy.Module instance. Parameters ---------- native_module The module in the native framework to convert, required if native_module_class is not given. Default is ``None``. native_module_class The class of the native module, required if na... |
146,441 | import ivy
def array(obj, dtype=None, copy=True, ndmin=4):
ret = ivy.array(obj, dtype=dtype, copy=copy)
while ndmin > len(ret.shape):
ret = ivy.expand_dims(ret, axis=0)
return ret | null |
146,442 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def adaptive_avg_pool2d(input, output_size):
return ivy.adaptive_avg_pool2d(input, output_size, ... | null |
146,443 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def pad(input, pad_width, mode="constant", constant_values=0):
return ivy.pad(input, pad_width, m... | null |
146,444 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def _conv(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1):
dims = len(input.... | null |
146,445 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def _conv(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1):
def conv2d(
inpu... | null |
146,446 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def _conv(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1):
def conv3d(
inpu... | null |
146,447 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def dropout(input, p=0.5, training=True, seed=None):
return ivy.dropout(input, p, training=train... | null |
146,448 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def dropout2d(input, p=0.5, training=True):
return ivy.dropout2d(input, p, training=training, da... | null |
146,449 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def dropout3d(input, p=0.5, training=True):
return ivy.dropout3d(input, p, training=training, da... | null |
146,450 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def fast_gelu(input_x):
return (input_x / (1 + ivy.exp(-1.702 * ivy.abs(input_x)))) * ivy.exp(
... | null |
146,451 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def flatten(input, order="C", *, start_dim=1, end_dim=-1):
return ivy.flatten(input, order=order... | null |
146,452 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def gumbel_softmax(logits, tau=1, hard=False, dim=-1):
gumbels = -ivy.empty_like(logits).exponen... | null |
146,453 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def hardswish(x):
return ivy.hardswish(x) | null |
146,454 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def interpolate(
input,
size=None,
scale_factor=None,
mode="nearest",
align_corn... | null |
146,455 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
The provided code snippet includes necessary dependencies for implementing the `kl_div` function. Wr... | Computes the Kullback-Leibler (KL) Divergence between the logits and the labels. Parameters ---------- logits (numpy array): The input logits array. labels (numpy array): The label array which has the same shape as logits. reduction (str): Specifies the reduction to be applied to the output. Its value must be one of 'n... |
146,456 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def log_softmax(input, axis=-1):
return ivy.log_softmax(input) | null |
146,457 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def max_pool3d(
input,
kernel_size,
stride=None,
padding=0,
dilation=1,
ceil... | null |
146,458 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def selu(input_x):
return ivy.selu(input_x) | null |
146,459 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def softshrink(x, lambd=0.5):
low = ivy.where(ivy.less(input, -lambd), ivy.add(input, lambd), 0)... | null |
146,460 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
def softsign(x):
return ivy.divide(x, ivy.add(1, ivy.abs(x))) | null |
146,461 | import ivy
from ivy.func_wrapper import with_unsupported_dtypes, with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import (
to_ivy_arrays_and_back,
)
from ivy.utils.assertions import check_equal
def affine_grid(theta, out_shape, align_corners=True):
if len(out_shape) == 4:
N, C, H... | null |
146,462 | import ivy
from ivy.func_wrapper import with_unsupported_dtypes, with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import (
to_ivy_arrays_and_back,
)
from ivy.utils.assertions import check_equal
def channel_shuffle(x, groups, data_format="NCHW", name=None):
if len(ivy.shape(x)) != 4:
... | null |
146,463 | import ivy
from ivy.func_wrapper import with_unsupported_dtypes, with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import (
to_ivy_arrays_and_back,
)
from ivy.utils.assertions import check_equal
def check_equal(x1, x2, inverse=False, message="", as_array=True):
def pixel_shuffle(x, upscale_f... | null |
146,464 | import ivy
from ivy.func_wrapper import with_unsupported_dtypes, with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import (
to_ivy_arrays_and_back,
)
from ivy.utils.assertions import check_equal
def pixel_unshuffle(x, downscale_factor, data_format="NCHW"):
if len(ivy.shape(x)) != 4:
... | null |
146,465 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
def layer_norm(x, normalized_shape, weight=None, bias=None, epsilon=1e-05, name=None):
return ivy.layer_norm(x, normalized_shape, scale=weight, offset=bias, eps=epsilon) | null |
146,466 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
def normalize(x, p=2, axis=1, epsilon=1e-12, name=None):
if axis < 0:
axis = ivy.get_num_dims(x) + axis
return ivy.lp_normalize(x, p=p, axis=axis) | null |
146,467 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.torch.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.torch.nn.functional import convolution_functions
def _conv(
x, weight, bias=None, stride=1, padding=0, dilation=1, groups=1, data_format="NLC"
):... | null |
146,468 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.torch.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.torch.nn.functional import convolution_functions
def _conv_transpose(
x,
weight,
bias=None,
stride=1,
padding=0,
output_paddi... | null |
146,469 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.torch.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.torch.nn.functional import convolution_functions
def _conv(
x, weight, bias=None, stride=1, padding=0, dilation=1, groups=1, data_format="NLC"
):... | null |
146,470 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.torch.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.torch.nn.functional import convolution_functions
def _conv_transpose(
x,
weight,
bias=None,
stride=1,
padding=0,
output_paddi... | null |
146,471 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.torch.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.torch.nn.functional import convolution_functions
def _conv(
x, weight, bias=None, stride=1, padding=0, dilation=1, groups=1, data_format="NLC"
):... | null |
146,472 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.torch.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.torch.nn.functional import convolution_functions
def _conv_transpose(
x,
weight,
bias=None,
stride=1,
padding=0,
output_paddi... | null |
146,473 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.paddle.tensor.math import tanh as paddle_tanh
def celu(
x,
/,
*,
alpha=1.0,
name=None,
):
return ivy.celu(x, alpha=alpha) | null |
146,474 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.paddle.tensor.math import tanh as paddle_tanh
def elu(
x,
/,
*,
alpha=1.0,
name=None,
):
return ivy.elu(x, alpha=alpha) | null |
146,475 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.paddle.tensor.math import tanh as paddle_tanh
def gelu(x, approximate=False, name=None):
return ivy.gelu(x, approximate=approximate) | null |
146,476 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.paddle.tensor.math import tanh as paddle_tanh
def glu(x, axis=-1, name=None):
size = x.shape[axis]
ivy.utils.assertions.check_equal(
... | null |
146,477 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.paddle.tensor.math import tanh as paddle_tanh
def gumbel_softmax(x, temperature=1.0, hard=False, axis=-1, name=None):
gumbel_noice = -ivy.log(-... | null |
146,478 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.paddle.tensor.math import tanh as paddle_tanh
def hardshrink(x, threshold=0.5, name=None):
mask = ivy.logical_or(ivy.greater(x, threshold), ivy... | null |
146,479 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.paddle.tensor.math import tanh as paddle_tanh
def hardsigmoid(x, slope=0.1666667, offset=0.5, name=None):
ret = ivy.minimum(ivy.maximum(ivy.add... | null |
146,480 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.paddle.tensor.math import tanh as paddle_tanh
def relu6(x, name=None):
return ivy.relu6(x)
def hardswish(x, name=None):
relu6_val = ivy.rel... | null |
146,481 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.paddle.tensor.math import tanh as paddle_tanh
def hardtanh(
x,
/,
*,
min=-1.0,
max=1.0,
name=None,
):
less = ivy.where(... | null |
146,482 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.paddle.tensor.math import tanh as paddle_tanh
def leaky_relu(x, negative_slope=0.01, name=None):
return ivy.leaky_relu(x) | null |
146,483 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.paddle.tensor.math import tanh as paddle_tanh
def softplus(x, beta=1, threshold=20, name=None):
return ivy.softplus(x, beta=beta, threshold=thre... | null |
146,484 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.paddle.tensor.math import tanh as paddle_tanh
def log_softmax(x, axis=-1, dtype=None, name=None):
x = ivy.astype(x, dtype) if dtype else x
... | null |
146,485 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.paddle.tensor.math import tanh as paddle_tanh
def mish(x, name=None):
return ivy.mish(x) | null |
146,486 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.paddle.tensor.math import tanh as paddle_tanh
def prelu(x, weight, data_format="NCHW", name=None):
return ivy.add(ivy.maximum(0, x), ivy.multip... | null |
146,487 | import ivy
from ivy.func_wrapper import with_supported_dtypes
from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
from ivy.functional.frontends.paddle.tensor.math import tanh as paddle_tanh
def relu(x, name=None):
def relu_(x, name=None):
ret = ivy.relu(x)
ivy.inplace_update(x, ret)... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.