id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
145,043
from socketify import App, AppOptions, OpCode, CompressOptions backpressure = 1024 messages = 0 message_number = 0 def ws_drain(ws): # Continue sending when we have drained (some) global message_number global messages while ws.get_buffered_amount() < backpressure: ws.send("This is a message, le...
null
145,044
import dataclasses import strawberry import strawberry.utils.graphiql from socketify import App from typing import List, Optional schema = strawberry.Schema(Query) async def graphiql_post(res, req): # we can pass whatever we want to context, query, headers or params, cookies etc context_value = req.preserve() ...
null
145,045
from socketify import App, AppOptions, AppListenOptions import asyncio async def delayed_hello(delay, res): await asyncio.sleep(delay) # do something async res.cork_end("Hello with delay!") def home(res, req): # request object only lives during the life time of this call # get parameters, query, heade...
null
145,046
from socketify import App, AppOptions, AppListenOptions import asyncio async def json(res, req): # request object only lives during the life time of this call # get parameters, query, headers anything you need here before first await :) user_agent = req.get_header("user-agent") # req maybe will not be ...
null
145,047
from socketify import App, AppOptions, AppListenOptions import asyncio def not_found(res, req): res.write_status(404).end("Not Found")
null
145,048
from socketify import App async def get_user(authorization): if authorization: # do actually something async here return {"greeting": "Hello, World"} return None def auth(route): # in async query string, arguments and headers are only valid until the first await async def auth_middlewar...
null
145,049
from socketify import App def home(res, req, user=None): theme = req.get_query("theme_color") theme = theme if theme else "light" greeting = user.get("greeting", None) user_id = req.get_parameter(0) res.cork_end(f"{greeting} <br/> theme: {theme} <br/> id: {user_id}")
null
145,050
import warnings from typing import Any, cast, TYPE_CHECKING, Union import jax._src.traceback_util as traceback_util import jax.core import jax.numpy as jnp import numpy as np from jaxtyping import Array, ArrayLike, Bool, Int from ._doc_utils import doc_repr from ._errors import branched_error_if from ._module import fi...
null
145,051
import warnings from typing import Any, cast, TYPE_CHECKING, Union import jax._src.traceback_util as traceback_util import jax.core import jax.numpy as jnp import numpy as np from jaxtyping import Array, ArrayLike, Bool, Int from ._doc_utils import doc_repr from ._errors import branched_error_if from ._module import fi...
null
145,052
import types from collections.abc import Callable from typing import Any, Generic, TYPE_CHECKING, TypeVar, Union from typing_extensions import ParamSpec import jax import jax.numpy as jnp import jax.tree_util as jtu from jaxtyping import PyTree from .._module import field, Module from .._pretty_print import bracketed, ...
This function is the most common API for working with stateful models. This initialises both the parameters and the state of a stateful model. `eqx.nn.make_with_state(Model)(*args, **kwargs)` simply calls `model_with_state = Model(*args, **kwargs)`, and then partitions the resulting PyTree into two pieces: the paramete...
145,053
import itertools as it import math from collections.abc import Callable, Sequence from typing import Optional, TypeVar, Union import jax import jax.lax as lax import jax.numpy as jnp import jax.random as jrandom import numpy as np from jaxtyping import Array, PRNGKeyArray from .._module import field, Module from ._misc...
null
145,054
from typing import Generic, Optional, TypeVar import jax import jax.lax as lax import jax.numpy as jnp import jax.random as jr from jaxtyping import Array, Float, PRNGKeyArray from .._module import field from .._tree import tree_at from ._sequential import StatefulLayer from ._stateful import State, StateIndex def _po...
null
145,055
import functools as ft import math import warnings from functools import partial from typing import cast, Optional, Union import jax import jax.numpy as jnp import jax.random as jrandom from jaxtyping import Array, Bool, Float, PRNGKeyArray from .._module import field, Module from ._dropout import Dropout from ._linear...
null
145,056
import typing_extensions as te from collections.abc import Sequence from typing import Any, TYPE_CHECKING, TypeVar, Union _T = TypeVar("_T", bound=Sequence) def all_sequences( x: Union[Sequence[Any], Sequence[_T]], ) -> "te.StrictTypeGuard[Sequence[_T]]": ...
null
145,057
import typing_extensions as te from collections.abc import Sequence from typing import Any, TYPE_CHECKING, TypeVar, Union _T = TypeVar("_T", bound=Sequence) def all_sequences(x: Union[Sequence[Any], Sequence[_T]]) -> bool: return all(isinstance(xi, Sequence) for xi in x)
null
145,058
import functools as ft from collections.abc import Callable from typing import Generic, Optional, TypeVar import jax import jax.numpy as jnp from jaxtyping import Array, PRNGKeyArray, Scalar from .._module import field, Module from .._tree import tree_at def _norm_except_axis(v: Array, norm: Callable[[Array], Scalar],...
null
145,059
import jax.tree_util as jtu from jaxtyping import PyTree from .._tree import tree_at def _inferences(pytree): is_leaf = lambda x: hasattr(x, "inference") and x is not pytree out = [pytree.inference] if hasattr(pytree, "inference") else [] leaves = [x for x in jtu.tree_leaves(pytree, is_leaf=is_leaf) if is_l...
Convenience function for setting all `inference` attributes. `inference` flags are used to toggle the behaviour of a number of the pre-built neural network layers, such as [`equinox.nn.Dropout`][] or [`equinox.nn.BatchNorm`][]. !!! Example ```python class Model(eqx.Module): norm: eqx.nn.BatchNorm dropout: eqx.nn.Dropou...
145,060
import math from collections.abc import Callable, Sequence from typing import Optional, Union import jax import jax.lax as lax import jax.numpy as jnp import jax.random from jaxtyping import Array, PRNGKeyArray from .._module import field, Module from ._misc import all_sequences The provided code snippet includes nece...
**Arguments:** - `x`: The input. Should be a JAX array of shape `(dim,)`. - `target_size`: The shape of the output after the pooling operation `(target_size,)`. - `operation`: The pooling operation to be performed on the input array. **Returns:** A JAX array of shape `(1, target_shape)`.
145,061
import dataclasses import functools as ft import inspect import warnings from collections.abc import Callable, Hashable from typing import Any, Literal, Optional, overload, Union import jax import jax._src.traceback_util as traceback_util import jax.core import jax.interpreters.batching as batching import jax.interpret...
null
145,062
import dataclasses import functools as ft import inspect import warnings from collections.abc import Callable, Hashable from typing import Any, Literal, Optional, overload, Union import jax import jax._src.traceback_util as traceback_util import jax.core import jax.interpreters.batching as batching import jax.interpret...
null
145,063
import dataclasses import functools as ft import inspect import warnings from collections.abc import Callable, Hashable from typing import Any, Literal, Optional, overload, Union import jax import jax._src.traceback_util as traceback_util import jax.core import jax.interpreters.batching as batching import jax.interpret...
null
145,064
import dataclasses import functools as ft import inspect import warnings from collections.abc import Callable, Hashable from typing import Any, Literal, Optional, overload, Union import jax import jax._src.traceback_util as traceback_util import jax.core import jax.interpreters.batching as batching import jax.interpret...
null
145,065
import dataclasses import functools as ft import inspect import warnings from collections.abc import Callable, Hashable from typing import Any, Literal, Optional, overload, Union import jax import jax._src.traceback_util as traceback_util import jax.core import jax.interpreters.batching as batching import jax.interpret...
Vectorises a function. By default, all JAX/NumPy arrays are vectorised down their leading axis (i.e. axis index 0), and all other types are broadcast. **Arguments:** For both `in_axes` and `out_axes`, then `int` indicates an array axis to vectorise over, `None` indicates that an argument should be broadcast (not vector...
145,066
import dataclasses import functools as ft import inspect import warnings from collections.abc import Callable, Hashable from typing import Any, Literal, Optional, overload, Union import jax import jax._src.traceback_util as traceback_util import jax.core import jax.interpreters.batching as batching import jax.interpret...
null
145,067
import dataclasses import functools as ft import inspect import warnings from collections.abc import Callable, Hashable from typing import Any, Literal, Optional, overload, Union import jax import jax._src.traceback_util as traceback_util import jax.core import jax.interpreters.batching as batching import jax.interpret...
null
145,068
import dataclasses import functools as ft import inspect import warnings from collections.abc import Callable, Hashable from typing import Any, Literal, Optional, overload, Union import jax import jax._src.traceback_util as traceback_util import jax.core import jax.interpreters.batching as batching import jax.interpret...
null
145,069
import dataclasses import functools as ft import inspect import warnings from collections.abc import Callable, Hashable from typing import Any, Literal, Optional, overload, Union import jax import jax._src.traceback_util as traceback_util import jax.core import jax.interpreters.batching as batching import jax.interpret...
null
145,070
import dataclasses import functools as ft import inspect import warnings from collections.abc import Callable, Hashable from typing import Any, Literal, Optional, overload, Union import jax import jax._src.traceback_util as traceback_util import jax.core import jax.interpreters.batching as batching import jax.interpret...
null
145,071
import dataclasses import functools as ft import inspect import warnings from collections.abc import Callable, Hashable from typing import Any, Literal, Optional, overload, Union import jax import jax._src.traceback_util as traceback_util import jax.core import jax.interpreters.batching as batching import jax.interpret...
!!! warning JAX has now added more powerful parallelism APIs directly to the JIT interface. As such, using [`equinox.filter_jit`][] with sharded inputs is now recommended over `filter_pmap`. See also the [parallelism example](../../../examples/parallelism/). Parallelises a function. By default, all JAX/NumPy arrays are...
145,072
internal_caches = [] internal_lru_caches = [] The provided code snippet includes necessary dependencies for implementing the `clear_caches` function. Write a Python function `def clear_caches()` to solve the following problem: Clears internal Equinox caches. Best used before calling `jax.clear_caches()` or `jax.clear_...
Clears internal Equinox caches. Best used before calling `jax.clear_caches()` or `jax.clear_backends()`. **Arguments:** None. **Returns:** None.
145,073
import inspect import typing from typing import TYPE_CHECKING, TypeVar class WithRepr(type): def __new__(mcs, obj, string): out = super().__new__(mcs, string, (), {}) # prevent the custom typing repr from doing the wrong thing out.__module__ = "builtins" return out def __init__(c...
null
145,074
import inspect import typing from typing import TYPE_CHECKING, TypeVar def doc_remove_args(*args): def doc_remove_args_impl(fn): if getattr(typing, "GENERATING_DOCUMENTATION", False): sig = inspect.signature(fn) new_params = [] for param in sig.parameters.values(): ...
null
145,075
import functools as ft from collections.abc import Callable from typing import Any, Union import jax import jax._src.traceback_util as traceback_util import jax.tree_util as jtu from jaxtyping import PyTree from ._caches import internal_lru_caches from ._filters import combine, is_array, partition from ._module import ...
null
145,076
import functools as ft import types import warnings import weakref from collections.abc import Callable import jax import jax.tree_util as jtu from jaxtyping import PyTree from ._caches import internal_caches from ._module import Module def _strip_wrapped_partial(fun): def _default_cache_key(): def get_fn_names(user_fn...
null
145,077
import abc import dataclasses from typing import ( Annotated, ClassVar, Generic, get_args, get_origin, TYPE_CHECKING, TypeVar, ) from typing_extensions import dataclass_transform, TypeAlias def _process_annotation(annotation): if isinstance(annotation, str): if annotation.startsw...
null
145,078
from typing import cast import jax import jax.core import jax.interpreters.batching as batching import jax.interpreters.mlir as mlir import jax.numpy as jnp from jaxtyping import Array, ArrayLike, Bool, Int def _unvmap_all_impl(x): return jnp.all(x)
null
145,079
from typing import cast import jax import jax.core import jax.interpreters.batching as batching import jax.interpreters.mlir as mlir import jax.numpy as jnp from jaxtyping import Array, ArrayLike, Bool, Int def _unvmap_all_abstract_eval(x): return jax.core.ShapedArray(shape=(), dtype=jax.numpy.bool_.dtype) # pyri...
null
145,080
from typing import cast import jax import jax.core import jax.interpreters.batching as batching import jax.interpreters.mlir as mlir import jax.numpy as jnp from jaxtyping import Array, ArrayLike, Bool, Int def unvmap_all(x: Bool[ArrayLike, "..."]) -> Bool[Array, ""]: """As `jnp.all`, but ignores batch dimensions."...
null
145,081
from typing import cast import jax import jax.core import jax.interpreters.batching as batching import jax.interpreters.mlir as mlir import jax.numpy as jnp from jaxtyping import Array, ArrayLike, Bool, Int def _unvmap_any_impl(x): return jnp.any(x)
null
145,082
from typing import cast import jax import jax.core import jax.interpreters.batching as batching import jax.interpreters.mlir as mlir import jax.numpy as jnp from jaxtyping import Array, ArrayLike, Bool, Int def _unvmap_any_abstract_eval(x): return jax.core.ShapedArray(shape=(), dtype=jax.numpy.bool_.dtype) # pyri...
null
145,083
from typing import cast import jax import jax.core import jax.interpreters.batching as batching import jax.interpreters.mlir as mlir import jax.numpy as jnp from jaxtyping import Array, ArrayLike, Bool, Int batching.primitive_batchers[unvmap_all_p] = _unvmap_all_batch def unvmap_any(x: Bool[ArrayLike, "..."]) -> Bool[...
null
145,084
from typing import cast import jax import jax.core import jax.interpreters.batching as batching import jax.interpreters.mlir as mlir import jax.numpy as jnp from jaxtyping import Array, ArrayLike, Bool, Int def _unvmap_max_impl(x): return jnp.max(x)
null
145,085
from typing import cast import jax import jax.core import jax.interpreters.batching as batching import jax.interpreters.mlir as mlir import jax.numpy as jnp from jaxtyping import Array, ArrayLike, Bool, Int def _unvmap_max_abstract_eval(x): return jax.core.ShapedArray(shape=(), dtype=x.dtype)
null
145,086
from typing import cast import jax import jax.core import jax.interpreters.batching as batching import jax.interpreters.mlir as mlir import jax.numpy as jnp from jaxtyping import Array, ArrayLike, Bool, Int batching.primitive_batchers[unvmap_all_p] = _unvmap_all_batch batching.primitive_batchers[unvmap_any_p] = _unvma...
null
145,087
import abc import dataclasses import functools as ft import inspect import types import warnings import weakref from collections.abc import Callable from typing import Any, cast, Optional, Protocol, TYPE_CHECKING, TypeVar, Union from typing_extensions import dataclass_transform, ParamSpec import jax._src.traceback_util...
Deprecated in favour of [`equinox.field`][], i.e. `eqx.field(static=True)`.
145,088
import abc import dataclasses import functools as ft import inspect import types import warnings import weakref from collections.abc import Callable from typing import Any, cast, Optional, Protocol, TYPE_CHECKING, TypeVar, Union from typing_extensions import dataclass_transform, ParamSpec import jax._src.traceback_util...
null
145,089
import abc import dataclasses import functools as ft import inspect import types import warnings import weakref from collections.abc import Callable from typing import Any, cast, Optional, Protocol, TYPE_CHECKING, TypeVar, Union from typing_extensions import dataclass_transform, ParamSpec import jax._src.traceback_util...
null
145,090
import abc import dataclasses import functools as ft import inspect import types import warnings import weakref from collections.abc import Callable from typing import Any, cast, Optional, Protocol, TYPE_CHECKING, TypeVar, Union from typing_extensions import dataclass_transform, ParamSpec import jax._src.traceback_util...
null
145,091
import abc import dataclasses import functools as ft import inspect import types import warnings import weakref from collections.abc import Callable from typing import Any, cast, Optional, Protocol, TYPE_CHECKING, TypeVar, Union from typing_extensions import dataclass_transform, ParamSpec import jax._src.traceback_util...
null
145,092
import abc import dataclasses import functools as ft import inspect import types import warnings import weakref from collections.abc import Callable from typing import Any, cast, Optional, Protocol, TYPE_CHECKING, TypeVar, Union from typing_extensions import dataclass_transform, ParamSpec import jax._src.traceback_util...
null
145,093
import abc import dataclasses import functools as ft import inspect import types import warnings import weakref from collections.abc import Callable from typing import Any, cast, Optional, Protocol, TYPE_CHECKING, TypeVar, Union from typing_extensions import dataclass_transform, ParamSpec import jax._src.traceback_util...
null
145,094
import functools as ft import inspect import warnings from collections.abc import Callable from typing import Any, Literal, overload, TypeVar from typing_extensions import ParamSpec import jax import jax._src.traceback_util as traceback_util import jax.core from jaxtyping import PyTree from ._compile_utils import ( ...
null
145,095
import functools as ft import inspect import warnings from collections.abc import Callable from typing import Any, Literal, overload, TypeVar from typing_extensions import ParamSpec import jax import jax._src.traceback_util as traceback_util import jax.core from jaxtyping import PyTree from ._compile_utils import ( ...
null
145,096
import functools as ft import inspect import warnings from collections.abc import Callable from typing import Any, Literal, overload, TypeVar from typing_extensions import ParamSpec import jax import jax._src.traceback_util as traceback_util import jax.core from jaxtyping import PyTree from ._compile_utils import ( ...
null
145,097
import functools as ft import inspect import warnings from collections.abc import Callable from typing import Any, Literal, overload, TypeVar from typing_extensions import ParamSpec import jax import jax._src.traceback_util as traceback_util import jax.core from jaxtyping import PyTree from ._compile_utils import ( ...
null
145,098
import functools as ft import inspect import warnings from collections.abc import Callable from typing import Any, Literal, overload, TypeVar from typing_extensions import ParamSpec import jax import jax._src.traceback_util as traceback_util import jax.core from jaxtyping import PyTree from ._compile_utils import ( ...
null
145,099
import functools as ft import inspect import warnings from collections.abc import Callable from typing import Any, Literal, overload, TypeVar from typing_extensions import ParamSpec import jax import jax._src.traceback_util as traceback_util import jax.core from jaxtyping import PyTree from ._compile_utils import ( ...
An easier-to-use version of `jax.jit`. All JAX and NumPy arrays are traced, and all other types are held static. **Arguments:** - `fun` is a pure function to JIT compile. - `donate` indicates whether the buffers of JAX arrays are donated or not. It should either be: - `'all'`: donate all arrays and suppress all warning...
145,100
import jax.tree_util as jtu from jaxtyping import PyTree def _apply_update(u, p): if u is None: return p else: return p + u def _is_none(x): return x is None The provided code snippet includes necessary dependencies for implementing the `apply_updates` function. Write a Python function `def...
A `jax.tree_util.tree_map`-broadcasted version of ```python if update is None: return model else: return model + update ``` This is often useful when updating a model's parameters via stochastic gradient descent. (This function is essentially the same as `optax.apply_updates`, except that it understands `None`.) For ex...
145,101
from collections.abc import Callable, Sequence from typing import Any, Optional, TYPE_CHECKING, Union import jax.numpy as jnp import jax.tree_util as jtu import numpy as np from jaxtyping import Array, ArrayLike, Bool, Float, PyTree, PyTreeDef from ._custom_types import sentinel from ._doc_utils import doc_repr from ._...
Checks if the PyTree is well-formed: does it have no self-references, and does it have no duplicate layers. Precisely, a "duplicate layer" is any PyTree node with at least one child node. !!! info This is automatically called when creating an `eqx.Module` instance, to help avoid bugs from duplicating layers. !!! Exampl...
145,102
import functools as ft import inspect import warnings from collections.abc import Sequence from typing import Literal, Union import jax import jax._src.traceback_util as traceback_util import jax.core import jax.lax as lax import jax.numpy as jnp import jax.tree_util as jtu import numpy as np from jaxtyping import Arra...
null
145,103
import functools as ft import inspect import warnings from collections.abc import Sequence from typing import Literal, Union import jax import jax._src.traceback_util as traceback_util import jax.core import jax.lax as lax import jax.numpy as jnp import jax.tree_util as jtu import numpy as np from jaxtyping import Arra...
null
145,104
import functools as ft import inspect import warnings from collections.abc import Sequence from typing import Literal, Union import jax import jax._src.traceback_util as traceback_util import jax.core import jax.lax as lax import jax.numpy as jnp import jax.tree_util as jtu import numpy as np from jaxtyping import Arra...
Asserts that a particular array (or PyTree of arrays) is DCE'd.
145,105
import functools as ft import pathlib from collections.abc import Callable from contextlib import contextmanager from typing import Any, BinaryIO, Optional, Union import jax import jax.numpy as jnp import jax.tree_util as jtu import numpy as np from jaxtyping import PyTree from ._filters import is_array_like def _order...
Save the leaves of a PyTree to file. **Arguments:** - `path_or_file`: The file location to save values to or a binary file-like object. - `pytree`: The PyTree whose leaves will be saved. - `filter_spec`: Specifies how to save each kind of leaf. By default all JAX arrays, NumPy arrays, Python bool/int/float/complexes ar...
145,106
import functools as ft import pathlib from collections.abc import Callable from contextlib import contextmanager from typing import Any, BinaryIO, Optional, Union import jax import jax.numpy as jnp import jax.tree_util as jtu import numpy as np from jaxtyping import PyTree from ._filters import is_array_like def _order...
Load the leaves of a PyTree from a file. **Arguments:** - `path_or_file`: The file location to load values from or a binary file-like object. - `like`: A PyTree of same structure, and with leaves of the same type, as the PyTree being loaded. Those leaves which are loaded will replace the corresponding leaves of `like`....
145,107
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
null
145,108
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
null
145,109
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
null
145,110
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
null
145,111
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
null
145,112
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
Creates a function that computes the gradient of `fun`. The gradient will be computed with respect to all floating-point JAX/NumPy arrays in the first argument. (Which should be a PyTree.) Any nondifferentiable leaves in the first argument will have `None` as the gradient. **Arguments:** - `fun` is a pure function to d...
145,113
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
null
145,114
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
null
145,115
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
Filtered version of `jax.vjp`. **Arguments:** - `fun`: The function to be differentiated. Will be called as `fun(*primals)`. Can return an arbitrary PyTree. - `primals`: The arguments at which `fun` will be evaluated and differentiated. Can be arbitrary PyTrees. - `has_aux`: Indicates whether `fun` returns a pair, with...
145,116
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
null
145,117
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
null
145,118
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
null
145,119
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
Identity function, which raises an error if it is differentiated (in forward or reverse mode).
145,120
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
null
145,121
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
null
145,122
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
null
145,123
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
null
145,124
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
null
145,125
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
null
145,126
import functools as ft import types import typing import warnings from collections.abc import Callable, Sequence from typing import ( Any, cast, Literal, Optional, overload, TYPE_CHECKING, TypeVar, Union, ) from typing_extensions import ParamSpec import jax import jax._src.traceback_util...
Filtered version of `jax.checkpoint`. Gradient checkpointing is a technique for reducing memory usage during backpropagation, especially when used with reverse mode automatic differentiation (e.g., `jax.grad` or `equinox.filter_grad`). **Arguments:** - `fun`: The function to be checkpointed. Will be called as `fun(*arg...
145,127
import jax from ._filters import combine, is_array, partition from ._tree import tree_equal def _is_struct(x): return hasattr(x, "shape") and hasattr(x, "dtype") def is_array(element: Any) -> bool: """Returns `True` if `element` is a JAX array or NumPy array.""" return isinstance(element, (np.ndarray, np.g...
Calls a Python function inside a JIT region. As `jax.pure_callback` but accepts arbitrary Python objects as inputs and outputs. (Not just JAXable types.) **Arguments:** - `callback`: The Python function to call. - `args`, `kwargs`: The function will be called as `callback(*args, **kwargs)`. These may be arbitrary Pytho...
145,128
import jax import jax.core import jax.numpy as jnp from jaxtyping import Array def left_broadcast_to(arr: Array, shape: tuple[int, ...]) -> Array: arr = arr.reshape(arr.shape + (1,) * (len(shape) - arr.ndim)) return jnp.broadcast_to(arr, shape)
null
145,129
import jax import jax.core import jax.numpy as jnp from jaxtyping import Array def default_floating_dtype(): if jax.config.jax_enable_x64: # pyright: ignore return jnp.float64 else: return jnp.float32
null
145,130
import jax import jax._src.traceback_util as traceback_util import jax.core import jax.lax as lax from jaxtyping import Array, Bool from .._unvmap import unvmap_any def unvmap_any(x: Bool[ArrayLike, "..."]) -> Bool[Array, ""]: """As `jnp.any`, but ignores batch dimensions.""" return cast(Array, unvmap_any_p.bi...
As `jax.debug.breakpoint`, but only triggers if `pred` is True. **Arguments:** - `pred`: the predicate for whether to trigger the breakpoint. - `**kwargs`: any other keyword arguments to forward to `jax.debug.breakpoint`. **Returns:** Nothing.
145,131
from typing import Any import jax import jax._src.traceback_util as traceback_util import jax.core import jax.numpy as jnp import jax.tree_util as jtu from .._ad import filter_custom_vjp from .._errors import error_if from .._filters import filter, is_array_like from .._module import Module from .._pretty_print import ...
null
145,132
from typing import Any import jax import jax._src.traceback_util as traceback_util import jax.core import jax.numpy as jnp import jax.tree_util as jtu from .._ad import filter_custom_vjp from .._errors import error_if from .._filters import filter, is_array_like from .._module import Module from .._pretty_print import ...
null
145,133
from collections.abc import Callable from typing import Any import jax import jax.core import jax.interpreters.ad as ad import jax.interpreters.batching as batching import jax.interpreters.mlir as mlir import jax.tree_util as jtu from .._filters import combine, is_array, partition announce_jaxpr_p = jax.core.Primitive(...
Identity function on an arbitrary PyTree. Announces each time a JAX transform is applied (grad, vmap, etc.). !!! warning This API is not stable. It should be used for one-off debugging purposes only. **Arguments:** - `x`: a variable to intercept. - `intermediates`: whether to include intermediate transforms, that haven...
145,134
from collections.abc import Callable from typing import Any import jax import jax.core import jax.interpreters.ad as ad import jax.interpreters.batching as batching import jax.interpreters.mlir as mlir import jax.tree_util as jtu from .._filters import combine, is_array, partition def _impl(*x, stack, name, intermedia...
null
145,135
from collections.abc import Callable from typing import Any import jax import jax.core import jax.interpreters.ad as ad import jax.interpreters.batching as batching import jax.interpreters.mlir as mlir import jax.tree_util as jtu from .._filters import combine, is_array, partition def _abstract(*x, stack, name, interm...
null
145,136
from collections.abc import Callable from typing import Any import jax import jax.core import jax.interpreters.ad as ad import jax.interpreters.batching as batching import jax.interpreters.mlir as mlir import jax.tree_util as jtu from .._filters import combine, is_array, partition announce_jaxpr_p = jax.core.Primitive(...
null
145,137
from collections.abc import Callable from typing import Any import jax import jax.core import jax.interpreters.ad as ad import jax.interpreters.batching as batching import jax.interpreters.mlir as mlir import jax.tree_util as jtu from .._filters import combine, is_array, partition announce_jaxpr_p = jax.core.Primitive(...
null
145,138
from collections.abc import Callable from typing import Any import jax import jax.core import jax.interpreters.ad as ad import jax.interpreters.batching as batching import jax.interpreters.mlir as mlir import jax.tree_util as jtu from .._filters import combine, is_array, partition announce_jaxpr_p = jax.core.Primitive(...
null
145,139
from collections.abc import Callable from typing import Any import jax import jax.core import jax.interpreters.ad as ad import jax.interpreters.batching as batching import jax.interpreters.mlir as mlir import jax.tree_util as jtu from .._filters import combine, is_array, partition def _mlir(*x, stack, name, intermedia...
null
145,140
from collections.abc import Hashable import jax import jax.core import jax.numpy as jnp import jax.tree_util as jtu from jaxtyping import PyTree from .._doc_utils import WithRepr from .._filters import combine, is_array, partition from .._pretty_print import pformat_short_array_text, tree_pprint _dce_store = {} def _re...
Used to check whether a PyTree is DCE'd. (That is, whether this code has been removed in the compiler, due to dead code eliminitation.) `store_dce` must be used within a JIT'd function, and acts as the identity function. When the JIT'd function is called, then whether each array got DCE'd or not is recorded. This can s...
145,141
from collections.abc import Hashable import jax import jax.core import jax.numpy as jnp import jax.tree_util as jtu from jaxtyping import PyTree from .._doc_utils import WithRepr from .._filters import combine, is_array, partition from .._pretty_print import pformat_short_array_text, tree_pprint _dce_store = {} class ...
Used in conjunction with `equinox.debug.check_dce`; see documentation there. Must be called outside of any JIT'd function. **Arguments:** - `name`: Optional argument. Whatever name was used with `check_dce`. **Returns:** Nothing. DCE information is printed to stdout.
145,142
import functools as ft import inspect import weakref from collections.abc import Callable from typing import Optional, overload, TypeVar from typing_extensions import ParamSpec from .._custom_types import sentinel from .._eval_shape import filter_eval_shape from .._module import field, Module, module_update_wrapper fro...
null