class_docstr: This creates an ``Op`` from inputs and outputs lists of variables.
  The signature is similar to :func:`theano.function <theano.function>`
  and the resulting ``Op``'s perform will do the same operation as::
  
      orig_function(inputs, outputs, **kwargs)
  
  Currently does not support ``updates`` or ``givens`` argument.
  
  Parameters
  ----------
  
  inputs: list of :class:`Variable <theano.gof.Variable>`
  
  outputs: list of :class:`Variable <theano.gof.Variable>`
  
  inline: bool, optional
      Defaults to ``False``
  
      ``True`` : Cause the Op's original graph being used during
      compilation, the Op will not be visible in the compiled
      graph but rather its internal graph.
  
      ``False`` : will use a pre-compiled function inside.
  
  grad_overrides : single or list of {'default', OpFromGraph, callable, Variable with special type}, optional
      Defaults to ``'default'``.
      This argument is mutually exclusive with lop_overrides.
  
      ``'default'`` : Do not override, use default grad() result
  
      OpFromGraph instance : Override with another OpFromGraph, should
      accept inputs as the same order and types of ``inputs`` and ``output_grads``
      arguments as one would specify in grad() method.
  
      callable : Should take two args: ``inputs`` and ``output_grads``.
      Each argument is expected to be a list of :class:`Variable <theano.gof.Variable>`.
      Must return list of :class:`Variable <theano.gof.Variable>`.
  
      Variable :
          ``NullType() instance`` : Treat as non-differentiable
          ``DisconnectedType() instance`` : Treat as disconnected gradient, numerically gives zero
  
      list: Each OpFromGraph/callable must return a single
      :class:`Variable <theano.gof.Variable>`. Each list element corresponds to gradient of
      a specific input, length of list must be equal to number of inputs.
  
  lop_overrides : single or list of {'default', OpFromGraph, callable, Variable with special type}, optional
      Defaults to ``'default'``.
      This argument is mutually exclusive with ``grad_overrides``.
  
      ``'default'`` : Do not override, use default L_op() result
  
      OpFromGraph instance : Override with another OpFromGraph, should
      accept inputs as the same order and types of ``inputs``, ``outputs`` and ``output_grads``
      arguments as one would specify in grad() method.
  
      callable : Should take three args: ``inputs``, ``outputs`` and ``output_grads``.
      Each argument is expected to be a list of :class:`Variable <theano.gof.Variable>`.
      Must return list of :class:`Variable <theano.gof.Variable>`.
  
      Variable :
          ``NullType() instance`` : Treat as non-differentiable
          ``DisconnectedType() instance`` : Treat as disconnected gradient, numerically gives zero
  
      list: Each OpFromGraph/callable must return a single
      :class:`Variable <theano.gof.Variable>`. Each list element corresponds to gradient of
      a specific input, length of list must be equal to number of inputs.
  
  rop_overrides : single or list of {'default', OpFromGraph, callable, Variable with special type}, optional
      Defaults to ``default``.
  
      ``'default'`` : Do not override, use default R_op() result
  
      OpFromGraph instance : Override with another OpFromGraph, should
      accept inputs as the same order and types of ``inputs`` and ``eval_points``
      arguments as one would specify in R_op() method.
  
      callable : Should take two args: ``inputs`` and ``eval_points``.
      Each argument is expected to be a list of :class:`Variable <theano.gof.Variable>`.
      Must return list of :class:`Variable <theano.gof.Variable>`.
  
      Variable :
          ``NullType() instance`` : Treat as non-differentiable
          ``DisconnectedType() instance`` : Treat as zero since DisconnectedType is not yet supported in R_op
  
      list: Each OpFromGraph/callable must return a single
      :class:`Variable <theano.gof.Variable>`. Each list element corresponds
      to a specific output of R_op, length of list must be equal to number of outputs.
  
  connection_pattern : list of list
  
      If not ``None``, this will be used as the connection_pattern
      for this op.
  
  name : string, optional
      A name for debugging purposes
  
  \*\*kwargs : optional
      Check
      :func:`orig_function <theano.compile.function_module.orig_function>`
      for more arguments, only works when not inline.
  
  
  .. TODO:
      - examples for a multi-layer mlp. where?
      - __hash__, __eq__ otherwise won't merge, try
        gof.opt.is_same_graph_with_merge(op1.local_outputs, op2,
        local_outputs)
      - c_code() to remove the double overhead?
      - grad() make it support DisconnectedType and the new interface
      - add support for NullType and DisconnectedType when R_op supports them
      - check how it works with updates.
      - add test with constant as input or inside the inner graph.
      - Add support for the GPU? Probably just need an opt to remove transfer
      - Add support to pickle this Op.
      - Add support/test with random generator
      - Add optimization to removing unused inputs/outputs
      - Add optimization to work inplace on inputs when not inline
  
  Notes
  -----
  - We support shared variables in the inner graph. This is automatic
    and invisible to the user. They can be as input to the node or in
    the inner graph.
  - We support unused inputs. This is needed for the grad.
  - We support nested OpFromGraph.
  - ``inline=True`` will cause better runtime optimization at the cost
    of compilation time. Currently only works with ``fast_compile`` or
    ``fast_run`` mode.
  - For overriding, it's recommended to provide pure functions (no side
    effects like setting global variable) as callable(s). The callable(s)
    supplied for overriding gradient/rop will be called only once at the
    first call to grad/R_op, and will be converted to OpFromGraph instances.
  
  Examples
  --------
  
  Example 1:
  
  .. code-block:: python
  
      from theano import function, OpFromGraph, tensor
      x, y, z = tensor.scalars('xyz')
      e = x + y * z
      op = OpFromGraph([x, y, z], [e])
      # op behaves like a normal theano op
      e2 = op(x, y, z) + op(z, y, x)
      fn = function([x, y, z], [e2])
  
  Example 2 with shared variable:
  
  .. code-block:: python
  
      import numpy as np
      import theano
      from theano import config, function, OpFromGraph, tensor
      x, y, z = tensor.scalars('xyz')
      s = theano.shared(np.random.rand(2, 2).astype(config.floatX))
      e = x + y * z + s
      op = OpFromGraph([x, y, z], [e])
      # op behaves like a normal theano op
      e2 = op(x, y, z) + op(z, y, x)
      fn = function([x, y, z], [e2])
  
  Example 3 override gradient
  
  .. code-block:: python
  
      from theano import function, OpFromGraph, tensor, grad
      x, y, z = tensor.scalars('xyz')
      e = x + y * z
      def rescale_dy(inps, grads):
          x, y, z = inps
          g, = grads
          return z*2
      op = OpFromGraph(
          [x, y, z], [e], grad_overrides=['default', rescale_dy, 'default']
      e2 = op(x, y, z)
      dx, dy, dz = grad(e2, [x, y, z])
      fn = function([x, y, z], [dx, dy, dz])
      # the gradient wrt y is now doubled
      fn(2., 3., 4.) # [1., 8., 3.]
class_docstr_tok: ["This","creates","an","``","Op","``","from","inputs","and","outputs","lists","of","variables",".","The","signature","is","similar","to",":","func",":","`","theano.function","<","theano.function",">","`","and","the","resulting","``","Op","``","'s","perform","will","do","the","same","operation","as",":",":","orig_function","(","inputs",",","outputs",",","*","*","kwargs",")","Currently","does","not","support","``","updates","``","or","``","givens","``","argument",".","Parameters","--","--","--","--","--","inputs",":","list","of",":","class",":","`","Variable","<","theano.gof.Variable",">","`","outputs",":","list","of",":","class",":","`","Variable","<","theano.gof.Variable",">","`","inline",":","bool",",","optional","Defaults","to","``","False","``","``","True","``",":","Cause","the","Op","'s","original","graph","being","used","during","compilation",",","the","Op","will","not","be","visible","in","the","compiled","graph","but","rather","its","internal","graph",".","``","False","``",":","will","use","a","pre-compiled","function","inside",".","grad_overrides",":","single","or","list","of","{","'default","'",",","OpFromGraph",",","callable",",","Variable","with","special","type","}",",","optional","Defaults","to","``","'default","'","``",".","This","argument","is","mutually","exclusive","with","lop_overrides",".","``","'default","'","``",":","Do","not","override",",","use","default","grad","(",")","result","OpFromGraph","instance",":","Override","with","another","OpFromGraph",",","should","accept","inputs","as","the","same","order","and","types","of","``","inputs","``","and","``","output_grads","``","arguments","as","one","would","specify","in","grad","(",")","method",".","callable",":","Should","take","two","args",":","``","inputs","``","and","``","output_grads","``",".","Each","argument","is","expected","to","be","a","list","of",":","class",":","`","Variable","<","theano.gof.Variable",">","`",".","Must","return","list","of",":","class",":","`","Variable","<","theano.gof.Variable",">","`",".","Variable",":","``","NullType","(",")","instance","``",":","Treat","as","non-differentiable","``","DisconnectedType","(",")","instance","``",":","Treat","as","disconnected","gradient",",","numerically","gives","zero","list",":","Each","OpFromGraph\/callable","must","return","a","single",":","class",":","`","Variable","<","theano.gof.Variable",">","`",".","Each","list","element","corresponds","to","gradient","of","a","specific","input",",","length","of","list","must","be","equal","to","number","of","inputs",".","lop_overrides",":","single","or","list","of","{","'default","'",",","OpFromGraph",",","callable",",","Variable","with","special","type","}",",","optional","Defaults","to","``","'default","'","``",".","This","argument","is","mutually","exclusive","with","``","grad_overrides","``",".","``","'default","'","``",":","Do","not","override",",","use","default","L_op","(",")","result","OpFromGraph","instance",":","Override","with","another","OpFromGraph",",","should","accept","inputs","as","the","same","order","and","types","of","``","inputs","``",",","``","outputs","``","and","``","output_grads","``","arguments","as","one","would","specify","in","grad","(",")","method",".","callable",":","Should","take","three","args",":","``","inputs","``",",","``","outputs","``","and","``","output_grads","``",".","Each","argument","is","expected","to","be","a","list","of",":","class",":","`","Variable","<","theano.gof.Variable",">","`",".","Must","return","list","of",":","class",":","`","Variable","<","theano.gof.Variable",">","`",".","Variable",":","``","NullType","(",")","instance","``",":","Treat","as","non-differentiable","``","DisconnectedType","(",")","instance","``",":","Treat","as","disconnected","gradient",",","numerically","gives","zero","list",":","Each","OpFromGraph\/callable","must","return","a","single",":","class",":","`","Variable","<","theano.gof.Variable",">","`",".","Each","list","element","corresponds","to","gradient","of","a","specific","input",",","length","of","list","must","be","equal","to","number","of","inputs",".","rop_overrides",":","single","or","list","of","{","'default","'",",","OpFromGraph",",","callable",",","Variable","with","special","type","}",",","optional","Defaults","to","``","default","``",".","``","'default","'","``",":","Do","not","override",",","use","default","R_op","(",")","result","OpFromGraph","instance",":","Override","with","another","OpFromGraph",",","should","accept","inputs","as","the","same","order","and","types","of","``","inputs","``","and","``","eval_points","``","arguments","as","one","would","specify","in","R_op","(",")","method",".","callable",":","Should","take","two","args",":","``","inputs","``","and","``","eval_points","``",".","Each","argument","is","expected","to","be","a","list","of",":","class",":","`","Variable","<","theano.gof.Variable",">","`",".","Must","return","list","of",":","class",":","`","Variable","<","theano.gof.Variable",">","`",".","Variable",":","``","NullType","(",")","instance","``",":","Treat","as","non-differentiable","``","DisconnectedType","(",")","instance","``",":","Treat","as","zero","since","DisconnectedType","is","not","yet","supported","in","R_op","list",":","Each","OpFromGraph\/callable","must","return","a","single",":","class",":","`","Variable","<","theano.gof.Variable",">","`",".","Each","list","element","corresponds","to","a","specific","output","of","R_op",",","length","of","list","must","be","equal","to","number","of","outputs",".","connection_pattern",":","list","of","list","If","not","``","None","``",",","this","will","be","used","as","the","connection_pattern","for","this","op",".","name",":","string",",","optional","A","name","for","debugging","purposes","\\","*","\\","*","kwargs",":","optional","Check",":","func",":","`","orig_function","<","theano.compile.function_module.orig_function",">","`","for","more","arguments",",","only","works","when","not","inline",".","..","TODO",":","-","examples","for","a","multi-layer","mlp",".","where","?","-","__hash__",",","__eq__","otherwise","wo","n't","merge",",","try","gof.opt.is_same_graph_with_merge","(","op1.local_outputs",",","op2",",","local_outputs",")","-","c_code","(",")","to","remove","the","double","overhead","?","-","grad","(",")","make","it","support","DisconnectedType","and","the","new","interface","-","add","support","for","NullType","and","DisconnectedType","when","R_op","supports","them","-","check","how","it","works","with","updates",".","-","add","test","with","constant","as","input","or","inside","the","inner","graph",".","-","Add","support","for","the","GPU","?","Probably","just","need","an","opt","to","remove","transfer","-","Add","support","to","pickle","this","Op",".","-","Add","support\/test","with","random","generator","-","Add","optimization","to","removing","unused","inputs\/outputs","-","Add","optimization","to","work","inplace","on","inputs","when","not","inline","Notes","--","--","-","-","We","support","shared","variables","in","the","inner","graph",".","This","is","automatic","and","invisible","to","the","user",".","They","can","be","as","input","to","the","node","or","in","the","inner","graph",".","-","We","support","unused","inputs",".","This","is","needed","for","the","grad",".","-","We","support","nested","OpFromGraph",".","-","``","inline=True","``","will","cause","better","runtime","optimization","at","the","cost","of","compilation","time",".","Currently","only","works","with","``","fast_compile","``","or","``","fast_run","``","mode",".","-","For","overriding",",","it","'s","recommended","to","provide","pure","functions","(","no","side","effects","like","setting","global","variable",")","as","callable","(","s",")",".","The","callable","(","s",")","supplied","for","overriding","gradient\/rop","will","be","called","only","once","at","the","first","call","to","grad\/R_op",",","and","will","be","converted","to","OpFromGraph","instances",".","Examples","--","--","--","--","Example","1",":","..","code-block",":",":","python","from","theano","import","function",",","OpFromGraph",",","tensor","x",",","y",",","z","=","tensor.scalars","(","'xyz","'",")","e","=","x","+","y","*","z","op","=","OpFromGraph","(","[","x",",","y",",","z","]",",","[","e","]",")","#","op","behaves","like","a","normal","theano","op","e2","=","op","(","x",",","y",",","z",")","+","op","(","z",",","y",",","x",")","fn","=","function","(","[","x",",","y",",","z","]",",","[","e2","]",")","Example","2","with","shared","variable",":","..","code-block",":",":","python","import","numpy","as","np","import","theano","from","theano","import","config",",","function",",","OpFromGraph",",","tensor","x",",","y",",","z","=","tensor.scalars","(","'xyz","'",")","s","=","theano.shared","(","np.random.rand","(","2",",","2",")",".astype","(","config.floatX",")",")","e","=","x","+","y","*","z","+","s","op","=","OpFromGraph","(","[","x",",","y",",","z","]",",","[","e","]",")","#","op","behaves","like","a","normal","theano","op","e2","=","op","(","x",",","y",",","z",")","+","op","(","z",",","y",",","x",")","fn","=","function","(","[","x",",","y",",","z","]",",","[","e2","]",")","Example","3","override","gradient","..","code-block",":",":","python","from","theano","import","function",",","OpFromGraph",",","tensor",",","grad","x",",","y",",","z","=","tensor.scalars","(","'xyz","'",")","e","=","x","+","y","*","z","def","rescale_dy","(","inps",",","grads",")",":","x",",","y",",","z","=","inps","g",",","=","grads","return","z","*","2","op","=","OpFromGraph","(","[","x",",","y",",","z","]",",","[","e","]",",","grad_overrides=","[","'default","'",",","rescale_dy",",","'default","'","]","e2","=","op","(","x",",","y",",","z",")","dx",",","dy",",","dz","=","grad","(","e2",",","[","x",",","y",",","z","]",")","fn","=","function","(","[","x",",","y",",","z","]",",","[","dx",",","dy",",","dz","]",")","#","the","gradient","wrt","y","is","now","doubled","fn","(","2.",",","3.",",","4",".",")","#","[","1.",",","8.",",","3",".","]"]
docstr: Set gradient overrides, see help(theano.OpFromGraph) for syntax
  This will completely remove any previously set L_op/gradient overrides
docstr_tok: ["Set","gradient","overrides",",","see","help","(","theano.OpFromGraph",")","for","syntax","This","will","completely","remove","any","previously","set","L_op\/gradient","overrides"]
code: def set_grad_overrides(self, grad_overrides):
      """
      Set gradient overrides, see help(theano.OpFromGraph) for syntax
      This will completely remove any previously set L_op/gradient overrides
  
      """
      self._lop_op = grad_overrides
      self._lop_op_is_cached = False
      self._lop_type = "grad"
      self._lop_is_default = grad_overrides == "default"
  
imports: from __future__ import absolute_import, division, print_function
  from functools import reduce, partial
  from collections import OrderedDict
  import theano
  from theano import gof
  from theano.compat import izip
  from theano.compile.function_module import orig_function
  from theano.compile import SharedVariable, rebuild_collect_shared, optdb
  from theano.gof import Variable, ops_with_inner_function
  from theano.gof.graph import io_connection_pattern
  from theano.gof.null_type import NullType
  from theano.gradient import DisconnectedType
label_desc: Use image node_id 11 for calling the OpFromGraph obj's underlying member method code with example usage: obj.set_grad_overrides(grad_overrides) without return types