code: def fgraph_updated_vars(fgraph, expanded_inputs):
      """
      Reconstruct the full "updates" dictionary, mapping from FunctionGraph input
      variables to the fgraph outputs that will replace their values.
  
      TODO: Get rid of all this `expanded_inputs` nonsense and use
      only `fgraph.update_mapping`.
  
      Returns
      -------
      dict variable -> variable
  
      """
      updated_vars = {}
  
      if len(expanded_inputs) != len(fgraph.inputs):
          raise ValueError(
              "expanded_inputs must match len(fgraph.inputs)"
          )
  
      for out_idx, in_idx in fgraph.update_mapping.items():
          assert expanded_inputs[in_idx].update is not None
          updated_vars[fgraph.inputs[in_idx]] = fgraph.outputs[out_idx]
  
      return updated_vars
  
imports: import copy
  import copyreg
  import logging
  import time
  import warnings
  from itertools import chain
  from typing import TYPE_CHECKING, Optional
  import numpy
  import pytensor
  import pytensor.compile.profiling
  from pytensor.compile.io import In, SymbolicInput, SymbolicOutput
  from pytensor.compile.ops import deep_copy_op, view_op
  from pytensor.configdefaults import config
  from pytensor.graph.basic import Constant, Variable, ancestors, clone_get_equiv, graph_inputs
  from pytensor.graph.destroyhandler import DestroyHandler
  from pytensor.graph.features import AlreadyThere, Feature, PreserveVariableAttributes
  from pytensor.graph.fg import FunctionGraph
  from pytensor.graph.op import HasInnerGraph
  from pytensor.graph.utils import InconsistencyError, get_variable_trace_string
  from pytensor.link.basic import Container
  from pytensor.link.utils import raise_with_op
label_desc: Use image node_id 4 for calling a global function with example usage: fgraph_updated_vars(fgraph, expanded_inputs) and returns: updated_vars