code: def reconstruct_graph(inputs, outputs, tag=None):
      """
      Different interface to clone, that allows you to pass inputs.
      Compared to clone, this method always replaces the inputs with
      new variables of the same type, and returns those (in the same
      order as the original inputs).
  
      """
      if tag is None:
          tag = ""
      nw_inputs = [safe_new(x, tag) for x in inputs]
  
      givens = {x: nw_x for nw_x, x in zip(nw_inputs, inputs)}
      nw_outputs = clone_replace(outputs, replace=givens)
      return (nw_inputs, nw_outputs)
  
imports: import copy
  import dataclasses
  import logging
  from collections import OrderedDict, namedtuple
  from collections.abc import Sequence
  from itertools import chain
  from typing import TYPE_CHECKING, Callable, Optional, Union
  from typing import cast
  import numpy
  from pytensor import scalar
  from pytensor import tensor
  from pytensor.compile.profiling import ProfileStats
  from pytensor.configdefaults import config
  from pytensor.graph.basic import Constant, Variable, equal_computations, graph_inputs
  from pytensor.graph.op import get_test_value
  from pytensor.graph.replace import clone_replace
  from pytensor.graph.type import HasDataType
  from pytensor.graph.utils import TestValueError
  from pytensor.tensor.basic import AllocEmpty, cast
  from pytensor.tensor.subtensor import set_subtensor
  from pytensor.tensor.variable import TensorConstant
label_desc: Use image node_id 6 for calling a global function with example usage: reconstruct_graph(inputs, outputs, tag) and returns: nw_inputs,  nw_outputs