code: def filter_primitive_transpose(
      rule=_sentinel, *, materialise_zeros=False
  ):
      """
      The `inputs` to the transpose rule are a PyTree like the primal
      inputs, with `UndefinedPrimal`s where appropriate.
  
      The `cts_out` passed to the transpose rule are a PyTree like the
      primal output, with `None` for symbolic zero cotangents, in particular
      for non-JAX-array-likes.
  
      The output from the rule should be a PyTree like the primal input.
      All leaves which were non-JAX-array-like, or which should have zero
      cotangent, should have cotangent `None`.
      """
      if rule is _sentinel:
          return ft.partial(
              filter_primitive_transpose,
              materialise_zeros=materialise_zeros,
          )
  
      def _wrapper(cts_out, *dynamic, treedef, static, flatten):
          treedef_out, _ = flatten.get()
          if materialise_zeros:
              cts_out = [ad.instantiate_zeros(ct) for ct in cts_out]
          else:
              cts_out = [
                  None if type(ct) is ad.Zero else ct for ct in cts_out
              ]
          cts_out = jtu.tree_unflatten(treedef_out, cts_out)
          wrapped_dynamic = [_wrap_undefined(x) for x in dynamic]
          wrapped_flat = _combine(wrapped_dynamic, static)
          wrapped_inputs = jtu.tree_unflatten(treedef, wrapped_flat)
          inputs = jtu.tree_map(_unwrap_undefined, wrapped_inputs)
          cts = rule(inputs, cts_out)
          flat_inputs, flat_cts = Flatten()(wrapped_inputs, cts)
          flat_inputs = [
              _unwrap_undefined(p, aval=True) for p in flat_inputs
          ]
          flat_cts = [
              _zero_from_primal(p) if ct is None else ct
              for p, ct in zip(flat_inputs, flat_cts)
          ]
          assert len(dynamic) == len(flat_cts)
          return flat_cts
  
      return _wrapper
  
imports: import functools
  from typing import Any
  import jax
  import jax.core
  import jax.interpreters.ad
  import jax.interpreters.batching
  import jax.interpreters.mlir
  import jax.tree_util
  from jaxtyping import PyTree
  from .._filters import combine, is_array, is_array_like, partition
  from .._tree import tree_equal
label_desc: Use image node_id 12 for calling a global function with example usage: filter_primitive_transpose(rule) and returns: _wrapper, ft, flat_cts