code: def std_fgraph(input_specs, output_specs, accept_inplace=False):
      """
      Makes an FunctionGraph corresponding to the input specs and the output
      specs.  Any SymbolicInput in the input_specs, if its update field
      is not None, will add an output to the FunctionGraph corresponding to that
      update. The return value is the FunctionGraph as well as a list of
      SymbolicOutput instances corresponding to the updates.
  
      If accept_inplace is False, the graph will be checked for inplace
      operations and an exception will be raised if it has any. If
      accept_inplace is True, a DestroyHandler will be added to the FunctionGraph
      if there are any inplace operations.
  
      The returned FunctionGraph is a clone of the graph between the provided
      inputs and outputs.
  
      """
      orig_inputs = [spec.variable for spec in input_specs]
  
      # Extract the updates and the mapping between update outputs and
      # the updated inputs.
      updates = []
      update_mapping = {}
      out_idx = len(output_specs)
      for inp_idx in range(len(input_specs)):
          if input_specs[inp_idx].update:
              updates.append(input_specs[inp_idx].update)
              update_mapping[out_idx] = inp_idx
              out_idx += 1
  
      orig_outputs = [spec.variable for spec in output_specs] + updates
  
      fgraph = gof.fg.FunctionGraph(
          orig_inputs, orig_outputs, update_mapping=update_mapping
      )
  
      for node in fgraph.apply_nodes:
          if getattr(node.op, "destroy_map", None):
              if not accept_inplace:
                  raise TypeError(
                      "Graph must not contain inplace operations",
                      node,
                      node.op,
                  )
              else:
                  fgraph.attach_feature(gof.DestroyHandler())
                  break
  
      # We need to protect all immutable inputs from inplace operations.
      fgraph.attach_feature(
          Supervisor(
              input
              for spec, input in zip(input_specs, fgraph.inputs)
              if not (
                  spec.mutable
                  or (
                      hasattr(fgraph, "destroyers")
                      and fgraph.has_destroyers([input])
                  )
              )
          )
      )
  
      # If named nodes are replaced, keep the name
      for feature in std_fgraph.features:
          fgraph.attach_feature(feature())
      return fgraph, list(map(SymbolicOutput, updates))
  
imports: from __future__ import absolute_import, print_function, division
  import copy
  from six import string_types, iteritems, iterkeys
  from six.moves import xrange
  import six.moves.copyreg
  import six.moves.cPickle
  from itertools import chain
  import time
  import warnings
  import numpy
  import theano
  from theano import config, gof
  from theano.compat import izip
  from theano.gof import graph
  import theano.compile.profiling
  from theano.compile.io import In, SymbolicInput, SymbolicOutput
  from theano.compile.ops import deep_copy_op, view_op
  from theano.gof.graph import is_same_graph
  from theano.gof.op import ops_with_inner_function
  import logging
label_desc: Use image node_id 5 for calling a global function with example usage: std_fgraph(input_specs, output_specs, accept_inplace) and returns: fgraph,  list