code: def _convert_inputs_to_reads(
      num_res: int, jaxpr: core.Jaxpr
  ) -> core.Jaxpr:
      assert not jaxpr.constvars, "Jaxpr should not have constvars"
  
      @lu.wrap_init
      def eval_jaxpr(*refs):
          residual_refs, orig_refs = split_list(refs, [num_res])
          residual_vals = [r[...] for r in residual_refs]
          () = core.eval_jaxpr(jaxpr, (), *residual_vals, *orig_refs)
          return []
  
      res_val_avals, orig_ref_avals = split_list(
          [v.aval for v in jaxpr.invars], [num_res]
      )
      res_ref_avals = [
          AbstractRef(aval)
          if not isinstance(aval, AbstractRef)
          else aval
          for aval in res_val_avals
      ]
      jaxpr, _, () = pe.trace_to_jaxpr_dynamic(
          eval_jaxpr, [*res_ref_avals, *orig_ref_avals]
      )
      return jaxpr
  
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 24 for calling a global function with example usage: _convert_inputs_to_reads(num_res, jaxpr) and returns: jaxpr, list