code: def infer_shape(outs, inputs, input_shapes):
      """
      Compute the shape of the outputs given the shape of the inputs of a theano
      graph.
  
      We do it this way to avoid compiling the inner function just to get
      the shape. Changes to ShapeFeature could require changes in this function.
  
      """
      # We use a ShapeFeature because it has all the necessary logic
      # inside.  We don't use the full ShapeFeature interface, but we
      # let it initialize itself with an empty fgraph, otherwise we will
      # need to do it manually
      for inp, inp_shp in izip(inputs, input_shapes):
          if inp_shp is not None and len(inp_shp) != inp.ndim:
              assert len(inp_shp) == inp.ndim
  
      shape_feature = tensor.opt.ShapeFeature()
      shape_feature.on_attach(theano.gof.FunctionGraph([], []))
  
      # Initialize shape_of with the input shapes
      for inp, inp_shp in izip(inputs, input_shapes):
          shape_feature.set_shape(inp, inp_shp)
  
      def local_traverse(out):
          """
          Go back in the graph, from out, adding computable shapes to shape_of.
  
          """
          if out in shape_feature.shape_of:
              # Its shape is already known
              return
          elif out.owner is None:
              # This is an input of the graph
              shape_feature.init_r(out)
          else:
              # Recurse over inputs
              for inp in out.owner.inputs:
                  if not inp in shape_feature.shape_of:
                      local_traverse(inp)
  
              # shape_feature.on_import does not actually use an fgraph
              # It will call infer_shape and set_shape appropriately
              dummy_fgraph = None
              shape_feature.on_import(
                  dummy_fgraph, out.owner, reason="dummy"
              )
  
      ret = []
      for o in outs:
          local_traverse(o)
          ret.append(shape_feature.shape_of[o])
      return ret
  
imports: from __future__ import absolute_import, print_function, division
  import copy
  import logging
  import warnings
  from collections import OrderedDict
  import numpy
  import theano
  from theano.compat import izip
  from six import string_types, iteritems
  from six.moves import xrange
  from theano.compile.pfunc import rebuild_collect_shared
  from theano import gof, compat
  from theano import tensor, scalar
  from theano.tensor.basic import get_scalar_constant_value
label_desc: Use image node_id 11 for calling a global function with example usage: infer_shape(outs, inputs, input_shapes) and returns: ret