code: def _convert_outputs_to_writes(
      jaxpr: core.Jaxpr,
  ) -> tuple[core.Jaxpr, list[core.ShapedArray]]:
      assert not jaxpr.constvars, "Jaxpr shouldn't have constvars."
  
      in_avals = [v.aval for v in jaxpr.invars]
  
      @lu.wrap_init
      def eval_jaxpr(*refs):
          # We split the refs into the original input refs and the dummy residual
          # refs.
          orig_refs, residual_refs = split_list(refs, [len(in_avals)])
          residual_vals = core.eval_jaxpr(jaxpr, (), *orig_refs)
          for res_ref, res_val in zip(residual_refs, residual_vals):
              res_ref[...] = res_val
          return []
  
      res_ref_avals = [
          AbstractRef(v.aval)
          if not isinstance(v.aval, AbstractRef)
          else v.aval
          for v in jaxpr.outvars
      ]
      jaxpr, _, consts = pe.trace_to_jaxpr_dynamic(
          eval_jaxpr, [*in_avals, *res_ref_avals]
      )
      assert not consts
      return jaxpr, [
          core.ShapedArray(
              a.inner_aval.shape, a.inner_aval.dtype
          )  # pytype: disable=attribute-error
          for a in res_ref_avals
      ]
  
imports: from __future__ import annotations
  from collections.abc import Sequence
  import dataclasses
  from functools import partial
  import operator
  from typing import Any, Callable, Protocol
  import numpy
  from jax._src import api_util
  from jax._src import ad_util
  from jax._src import config
  from jax._src import core
  from jax._src import linear_util
  from jax._src import source_info_util
  from jax._src import tree_util
  from jax._src.interpreters import ad
  from jax._src.interpreters import mlir
  from jax._src.interpreters import partial_eval
  from jax._src.lax import lax
  from jax._src.lax import slicing
  from jax._src.state import indexing
  from jax._src.state.types import AbstractRef, RefEffect
  from jax._src.state.primitives import get_p, swap_p, addupdate_p
  from jax._src.state.utils import hoist_consts_to_refs
  from jax._src.typing import Array
  from jax._src.util import safe_map, safe_zip, split_list, weakref_lru_cache, partition_list, merge_lists, split_dict
label_desc: Use image node_id 23 for calling a global function with example usage: _convert_outputs_to_writes(jaxpr) and returns: jaxpr,  unknown, list