graph_to_tree

Contents

graph_to_tree#

class brainstate.graph.graph_to_tree(may_have_graph_nodes, /, *, prefix=<class 'brainstate.typing.Missing'>, split_fn=<function _default_split_fn>, map_non_graph_nodes=False, check_aliasing=True)[source]#

Convert a pytree that may contain graph nodes into a pure pytree of NodeStates.

Return type:

tuple[PyTree, dict[tuple[TypeVar(KeyEntry), ...], int | Array | ndarray]]