class_docstr: Finish-to-start evalution order of thunks.
  
  This supports lazy evaluation of subtrees and partial
  computations of graphs when only some inputs have changed.
  
  At a pseudo-code level, the basic idea is the following:
  
  def recursively_evaluate(var):
      if var is up to date:
          return
      if var.owner.inputs are up to date:
          update var
          return
      for input in var.owner.unputs:
          recursively_evaluate(var)
  
  for output in outputs:
      recursively_evaluate(output)
  
  The actual logic is more complex to support intermediate
  garbage collection, lazily-evaluated nodes, and better speed.
class_docstr_tok: ["Finish-to-start","evalution","order","of","thunks",".","This","supports","lazy","evaluation","of","subtrees","and","partial","computations","of","graphs","when","only","some","inputs","have","changed",".","At","a","pseudo-code","level",",","the","basic","idea","is","the","following",":","def","recursively_evaluate","(","var",")",":","if","var","is","up","to","date",":","return","if","var.owner.inputs","are","up","to","date",":","update","var","return","for","input","in","var.owner.unputs",":","recursively_evaluate","(","var",")","for","output","in","outputs",":","recursively_evaluate","(","output",")","The","actual","logic","is","more","complex","to","support","intermediate","garbage","collection",",","lazily-evaluated","nodes",",","and","better","speed","."]
code: def __init__(
      self,
      nodes,
      thunks,
      pre_call_clear,
      storage_map,
      compute_map,
      fgraph,
      allow_gc,
      n_updates,
      dependencies=None,
      callback=None,
      callback_input=None,
  ):
      super(Stack, self).__init__(nodes, thunks, pre_call_clear)
  
      self.allow_gc = allow_gc
      self.message = ""
      self.base_apply_stack = [
          o.owner for o in fgraph.outputs if o.owner
      ]
      self.outputs = fgraph.outputs
      self.storage_map = storage_map
      self.variable_shape = {}  # Variable -> shape
      self.variable_strides = {}  # Variable -> strides
      self.variable_offset = {}  # Variable -> offset
      self.compute_map = compute_map
      self.node_idx = node_idx = {}
      self.callback = callback
      self.callback_input = callback_input
      self.n_updates = n_updates
  
      ords = fgraph.orderings()
  
      for i, node in enumerate(self.nodes):
          node_idx[node] = i
  
          # XXX: inconsistent style - why modify node here rather
          #      than track destroy_dependencies with dictionary like
          #      storage_map?
          #
          # destroy_dependencies
          # --------------------
          # The destroy_dependencies is a list of variables that are implicit
          # dependencies induced by destroy_map and view_map (compared to
          # node.inputs which are *explicit* dependencies). The variables in
          # destroy_dependencies would be impossible to compute after the
          # current `node` runs, because node.thunk() is going to destroy a
          # common input variable needed by whatever node owns each variable
          # in destroy_depenencies.
  
          node.destroy_dependencies = []
          if node in ords:
              for prereq in ords[node]:
                  node.destroy_dependencies += prereq.outputs
  
      self.dependencies = dependencies
  
      if self.allow_gc and self.dependencies is None:
          raise ValueError("Must set dependencies when using GC")
  
imports: from __future__ import absolute_import, print_function, division
  from .None import link
  from collections import defaultdict
  import logging
  import sys
  import time
  import warnings
  import platform
  from theano.configparser import config, _config_var_list
  import theano.gof.cmodule
  from six import iteritems, itervalues
  from six.moves import xrange
label_desc: Use image node_id 1 to create a new Stack object from inherited base classes: VM with example: obj = Stack(nodes, thunks, pre_call_clear, storage_map, compute_map, fgraph, allow_gc, n_updates, dependencies, callback, callback_input)