code: def tree_leaves(
      tree: PyTree,
      is_leaf: Optional[Callable[[PyTree], bool]] = None,
  ) -> List[Any]:
      """Get the leaves of a pytree.
  
      See also :func:`tree_flatten`.
  
      >>> tree = {'b': (2, [3, 4]), 'a': 1, 'c': None, 'd': 5}
      >>> tree_leaves(tree)
      [1, 2, 3, 4, None, 5]
      >>> tree_leaves(1)
      [1]
      >>> tree_leaves(None)
      [None]
  
      Args:
          tree (pytree): A pytree to flatten.
          is_leaf (callable, optional): An extra leaf predicate function that will be called at each
              flattening step. The function should have a single argument with signature
              ``is_leaf(node) -> bool``. If it returns :data:`True`, the whole subtree being treated
              as a leaf. Otherwise, the default pytree registry will be used to determine a node is a
              leaf or not. If the function is not specified, the default pytree registry will be used.
  
      Returns:
          A list of leaf values.
      """
      return optree.tree_leaves(
          tree,
          is_leaf=is_leaf,
          none_is_leaf=True,
          namespace="torch",
      )
  
imports: import functools
  import warnings
  from typing import Any, Callable, Iterable, List, Optional, overload, Tuple, Type, TypeVar, Union
  import torch
  import optree
  from optree import PyTreeSpec
label_desc: Use image node_id 7 for calling a global function with example usage: tree_leaves(tree, is_leaf) and returns: optree