code: def tree_check(pytree: Any) -> None:
      """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.
  
      !!! Example
  
          ```python
          a = 1
          eqx.tree_check([a, a])  # passes, duplicate is a leaf
  
          b = eqx.nn.Linear(...)
          eqx.tree_check([b, b])  # fails, duplicate is nontrivial!
  
          c = []  # empty list
          eqx.tree_check([c, c])  # passes, duplicate is trivial
  
          d = eqx.Module()
          eqx.tree_check([d, d])  # passes, duplicate is trivial
  
          eqx.tree_check([None, None])  # passes, duplicate is trivial
  
          e = [1]
          eqx.tree_check([e, e])  # fails, duplicate is nontrivial!
  
          eqx.tree_check([[1], [1]])  # passes, not actually a duplicate: each `[1]`
                                      # has the same structure, but they're different.
  
          # passes, not actually a duplicate: each Linear layer is a separate layer.
          eqx.tree_check([eqx.nn.Linear(...), eqx.nn.Linear(...)])
          ```
  
      **Arguments:**
  
      - `pytree`: the PyTree to check.
  
      **Returns:**
  
      Nothing.
  
      **Raises:**
  
      A `ValueError` if the PyTree is not well-formed.
      """
      all_nodes = {}
      _tree_check(pytree, all_nodes)
  
imports: from collections.abc import Callable, Sequence
  from typing import Any, Optional, TYPE_CHECKING, Union
  import jax.numpy
  import jax.tree_util
  import numpy
  from jaxtyping import Array, ArrayLike, Bool, Float, PyTree, PyTreeDef
  from ._custom_types import sentinel
  from ._doc_utils import doc_repr
  from ._filters import is_array
label_desc: Use image node_id 6 for calling a global function with example usage: tree_check(pytree) without return types