code: def orig_function(
      inputs,
      outputs,
      mode=None,
      accept_inplace=False,
      name=None,
      profile=None,
      on_unused_input=None,
      output_keys=None,
      fgraph: Optional[FunctionGraph] = None,
  ) -> Function:
      """
      Return a Function that will calculate the outputs from the inputs.
  
      Parameters
      ----------
      inputs : list of `SymbolicInput` or `In` instances
      outputs : a SymbolicOutput or a list of `SymbolicOutput` or `Out` instances
          The return value of the returned function will match the format of this
          argument (either the value itself or a list of one or more return
          values).
      mode : descriptive string or Mode instance
          Default of None means to use `config.mode` (see below for descriptive
          string list).
      name : str
          An optional name for this function. If used, the profile mode will print the
          time spent in this function.
      accept_inplace : bool
          True iff the graph can contain inplace operations prior to the
          rewrite phase (default is False).
      profile : None or ProfileStats instance
      on_unused_input : {'raise', 'warn', 'ignore', None}
          What to do if a variable in the 'inputs' list is not used in the graph.
      output_keys
          If the outputs were provided to pytensor.function as a list, then
          output_keys is None. Otherwise, if outputs were provided as a dict,
          output_keys is the sorted list of keys from the outputs.
      fgraph
          An existing `FunctionGraph` to use instead of constructing a new one
          from cloned `outputs`.
  
      """
  
      if profile:
          t1 = time.perf_counter()
      mode = pytensor.compile.mode.get_mode(mode)
  
      inputs = list(map(convert_function_input, inputs))
  
      if outputs is not None:
          if isinstance(outputs, (list, tuple)):
              outputs = list(map(FunctionMaker.wrap_out, outputs))
          else:
              outputs = FunctionMaker.wrap_out(outputs)
  
      defaults = [getattr(input, "value", None) for input in inputs]
  
      if isinstance(mode, (list, tuple)):
          raise ValueError(
              "We do not support the passing of multiple modes"
          )
  
      fn = None
      try:
          Maker = getattr(mode, "function_maker", FunctionMaker)
          m = Maker(
              inputs,
              outputs,
              mode,
              accept_inplace=accept_inplace,
              profile=profile,
              on_unused_input=on_unused_input,
              output_keys=output_keys,
              name=name,
              fgraph=fgraph,
          )
          with config.change_flags(compute_test_value="off"):
              fn = m.create(defaults)
      finally:
          if profile and fn:
              t2 = time.perf_counter()
              profile.compile_time += t2 - t1
              # TODO: append
              profile.nb_nodes = len(fn.maker.fgraph.apply_nodes)
  
      return fn
  
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 9 for calling a global function with example usage: orig_function(inputs, outputs, mode, accept_inplace, name, profile, on_unused_input, output_keys, fgraph) and returns: fn