class_docstr: Finish-to-start evaluation 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 as follows:
  
  .. code-block:: python
  
      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.inputs:
              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","evaluation","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","as","follows",":","..","code-block",":",":","python","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.inputs",":","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","."]
docstr: Parameters
  ----------
  allow_gc
      Determines whether or not garbage collection is performed.
  dependencies
      TODO
  callback
      TODO
  callback_input
      TODO
docstr_tok: ["Parameters","--","--","--","--","--","allow_gc","Determines","whether","or","not","garbage","collection","is","performed",".","dependencies","TODO","callback","TODO","callback_input","TODO"]
code: def __init__(
      self,
      fgraph,
      nodes,
      thunks,
      pre_call_clear,
      storage_map,
      input_storage,
      output_storage,
      update_vars,
      compute_map: "ComputeMapType",
      allow_gc: bool,
      dependencies: Optional[dict[Variable, list[Variable]]] = None,
      callback=None,
      callback_input=None,
  ):
      r"""
      Parameters
      ----------
      allow_gc
          Determines whether or not garbage collection is performed.
      dependencies
          TODO
      callback
          TODO
      callback_input
          TODO
      """
  
      super().__init__(
          fgraph,
          nodes,
          thunks,
          pre_call_clear,
          storage_map,
          input_storage,
          output_storage,
          update_vars,
      )
  
      self.update_vars = update_vars
      self.compute_map = compute_map
      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.variable_shape: dict[Variable, Any] = {}  # Variable -> shape
      self.variable_strides: dict[
          Variable, Any
      ] = {}  # Variable -> strides
      self.variable_offset: dict[
          Variable, Any
      ] = {}  # Variable -> offset
      node_idx = {node: i for i, node in enumerate(self.nodes)}
      self.node_idx = node_idx
      self.callback = callback
      self.callback_input = callback_input
      self.destroy_dependencies = get_destroy_dependencies(fgraph)
      self.dependencies = dependencies
  
      if self.allow_gc and self.dependencies is None:
          raise ValueError("Must set dependencies when using GC")
  
imports: import platform
  import sys
  import time
  import warnings
  from abc import ABC, abstractmethod
  from collections import defaultdict
  from collections.abc import Sequence
  from itertools import zip_longest
  from typing import TYPE_CHECKING, Any, Optional
  from pytensor.configdefaults import config
  from pytensor.graph.basic import Apply, Constant, Variable
  from pytensor.link.basic import Container, LocalLinker
  from pytensor.link.c.exceptions import MissingGXX
  from pytensor.link.utils import gc_helper, get_destroy_dependencies, map_storage, raise_with_op
label_desc: Use image node_id 1 to create a new Stack object from inherited base classes: UpdatingVM with example: obj = Stack(fgraph, nodes, thunks, pre_call_clear, storage_map, input_storage, output_storage, update_vars, compute_map, allow_gc, dependencies, callback, callback_input)