code: def assume_measured_ir_outputs(
      inputs: Sequence[TensorVariable],
      outputs: Sequence[TensorVariable],
  ) -> Sequence[TensorVariable]:
      """Run IR rewrite assuming each output is measured.
  
      IR variables could depend on each other in a way that looks unmeasurable without a value variable assigned to each.
      For instance `join([add(x, z), z])` is a potentially measurable join, but `add(x, z)` can look unmeasurable
      because neither `x` and `z` are valued in the IR representation.
      This helper runs an inner ir rewrite after giving each output a dummy value variable.
      We replace inputs by dummies and then undo it so that any dependency on outer variables is preserved.
      """
      # Replace inputs by dummy variables
      replaced_inputs = {
          var: var.type()
          for var in truncated_graph_inputs(
              outputs, ancestors_to_include=inputs
          )
          if var in inputs
      }
      cloned_outputs = clone_replace(outputs, replace=replaced_inputs)
  
      dummy_rv_values = {
          base_var: base_var.type() for base_var in cloned_outputs
      }
      fgraph, *_ = construct_ir_fgraph(dummy_rv_values)
  
      # Replace dummy variables by inputs
      fgraph.replace_all(
          tuple((repl, orig) for orig, repl in replaced_inputs.items()),
          import_missing=True,
      )
  
      return fgraph.outputs
  
imports: import warnings
  from collections import deque
  from typing import Dict, List, Optional, Sequence, Tuple
  import pytensor.tensor
  from pytensor import config
  from pytensor.compile.mode import optdb
  from pytensor.graph.basic import Constant, Variable, ancestors, io_toposort, truncated_graph_inputs
  from pytensor.graph.features import Feature
  from pytensor.graph.fg import FunctionGraph
  from pytensor.graph.replace import clone_replace
  from pytensor.graph.rewriting.basic import ChangeTracker, EquilibriumGraphRewriter, GraphRewriter, node_rewriter, out2in
  from pytensor.graph.rewriting.db import LocalGroupDB, RewriteDatabase, RewriteDatabaseQuery, SequenceDB, TopoDB
  from pytensor.tensor.basic import Alloc
  from pytensor.tensor.elemwise import DimShuffle, Elemwise
  from pytensor.tensor.random.rewriting import local_subtensor_rv_lift
  from pytensor.tensor.rewriting.basic import register_canonicalize
  from pytensor.tensor.rewriting.math import local_exp_over_1_plus_exp
  from pytensor.tensor.rewriting.shape import ShapeFeature
  from pytensor.tensor.rewriting.uncanonicalize import local_max_and_argmax
  from pytensor.tensor.subtensor import AdvancedIncSubtensor, AdvancedIncSubtensor1, AdvancedSubtensor, AdvancedSubtensor1, IncSubtensor, Subtensor
  from pytensor.tensor.variable import TensorVariable
  from pymc.logprob.abstract import MeasurableVariable
  from pymc.logprob.utils import DiracDelta, indices_from_subtensor
label_desc: Use image node_id 6 for calling a global function with example usage: assume_measured_ir_outputs(inputs, outputs) and returns: fgraph