code: def tree_serialise_leaves(
      path_or_file: Union[str, pathlib.Path, BinaryIO],
      pytree: PyTree,
      filter_spec=default_serialise_filter_spec,
      is_leaf: Optional[Callable[[Any], bool]] = None,
  ) -> None:
      """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 are saved,
          and all other leaf types are ignored. (See
          [`equinox.default_serialise_filter_spec`][].)
      - `is_leaf`: Called on every node of `pytree`; if `True` then this node will be
          treated as a leaf.
  
      **Returns:**
  
      Nothing.
  
      !!! example
  
          This can be used to save a model to file.
  
          ```python
          import equinox as eqx
          import jax.random as jr
  
          model = eqx.nn.MLP(2, 2, 2, 2, key=jr.PRNGKey(0))
          eqx.tree_serialise_leaves("some_filename.eqx", model)
          ```
  
      !!! info
  
          `filter_spec` should typically be a function `(File, Any) -> None`, which takes
          a file handle and a leaf to save, and either saves the leaf to the file or
          does nothing.
  
          It can also be a PyTree of such functions, in which case the PyTree structure
          should be a prefix of `pytree`, and each function will be mapped over the
          corresponding sub-PyTree of `pytree`.
      """
  
      with _maybe_open(path_or_file, "wb") as f:
  
          def _serialise(spec, x):
              def __serialise(y):
                  spec(f, y)
  
              _ordered_tree_map(__serialise, x, is_leaf=is_leaf)
  
          _ordered_tree_map(_serialise, filter_spec, pytree)
  
imports: import functools
  import pathlib
  from collections.abc import Callable
  from contextlib import contextmanager
  from typing import Any, BinaryIO, Optional, Union
  import jax
  import jax.numpy
  import jax.tree_util
  import numpy
  from jaxtyping import PyTree
  from ._filters import is_array_like
label_desc: Use image node_id 7 for calling a global function with example usage: tree_serialise_leaves(path_or_file, pytree, filter_spec, is_leaf) without return types