code: def donation_vector(
      donate_argnums, donate_argnames, args, kwargs
  ) -> tuple[bool, ...]:
      """Returns a tuple with a boolean value for each leaf in args and kwargs.
  
      What if a user specifies donate_argnums but calls the function with kwargs
      or vice-versa? In that case, in `resolve_argnums` using the signature of the
      function, the counterpart (donate_argnames or donate_argnums respectively) is
      calculated so when this function is called both donate_argnums and
      donate_argnames are available. This allows JAX to donate kwargs when only
      donate_argnums is specified and vice-versa.
  
      When both donate_argnums and donate_argnames are specified, only the args and
      kwargs specified are donated.
      """
      res: list[bool] = []
      for i, arg in enumerate(args):
          donate = bool(i in donate_argnums)
          res.extend((donate,) * tree_structure(arg).num_leaves)
      for key, val in kwargs.items():
          donate = key in donate_argnames
          res.extend((donate,) * tree_structure(val).num_leaves)
      return tuple(res)
  
imports: from __future__ import annotations
  from collections.abc import Iterable, Sequence
  import inspect
  import operator
  from functools import partial
  from typing import Any, Callable
  import warnings
  import numpy
  from jax._src import core
  from jax._src import dtypes
  from jax._src.abstract_arrays import numpy_scalar_types
  from jax._src.core import ShapedArray
  from jax._src.tree_util import PyTreeDef, tree_flatten, tree_unflatten, tree_map, tree_structure, treedef_children, generate_key_paths, keystr, broadcast_prefix, prefix_errors
  from jax._src.tree_util import _replace_nones
  from jax._src import linear_util
  from jax._src.linear_util import TracingDebugInfo
  from jax._src.util import safe_map, WrapKwArgs, Hashable, HashableFunction, Unhashable
  from jax._src import traceback_util
label_desc: Use image node_id 19 for calling a global function with example usage: donation_vector(donate_argnums, donate_argnames, args, kwargs) and returns: tuple