code: def finalise_jaxpr(
      jaxpr: jax.core.ClosedJaxpr,
  ) -> jax.core.ClosedJaxpr:
      """A jaxpr-to-jaxpr transformation that performs finalisation."""
      fn = finalise_jaxpr_as_fn(jaxpr)
      args = [
          jax.ShapeDtypeStruct(x.aval.shape, x.aval.dtype)
          for x in jaxpr.jaxpr.invars
      ]
      return cast(jax.core.ClosedJaxpr, jax.make_jaxpr(fn)(*args))
  
imports: import functools
  from collections.abc import Callable
  from typing import Any, cast, Literal, overload, Union
  import jax
  import jax.core
  import jax.custom_derivatives
  import jax.tree_util
  from jaxtyping import PyTree
  from .._unvmap import unvmap_all_p, unvmap_any_p, unvmap_max_p
  from ..debug._announce_transform import announce_jaxpr_p
  from ._loop import maybe_set_p, select_if_vmap_p
  from ._noinline import noinline_p
  from ._nontraceable import nonbatchable_p, nondifferentiable_backward_p, nontraceable_p
label_desc: Use image node_id 9 for calling a global function with example usage: finalise_jaxpr(jaxpr) and returns: cast