code: 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_leaf(x)
      ]
      # Nodes with an inference flag might have sub-nodes with an inference flag.
  
      for x in leaves:
          out.extend(_inferences(x))
      return out
  
imports: import jax.tree_util
  from jaxtyping import PyTree
  from .._tree import tree_at
label_desc: Use image node_id 1 for calling a global function with example usage: _inferences(pytree) and returns: out