

def on_attach(self, fgraph):
    "\n            When attaching to a new fgraph, check that\n            1) This DestroyHandler wasn't already attached to some fgraph\n               (its data structures are only set up to serve one)\n            2) The FunctionGraph doesn't already have a DestroyHandler.\n               This would result in it validating everything twice, causing\n               compilation to be slower.\n\n            TODO: WRITEME: what does this do besides the checks?\n\n            "
    already_there = False
    if (self.fgraph not in [None, fgraph]):
        raise Exception('A DestroyHandler instance can only serve one FunctionGraph. (Matthew 6:24)')
    for attr in ('destroyers', 'destroy_handler'):
        if hasattr(fgraph, attr):
            already_there = True
    if already_there:
        raise toolbox.AlreadyThere('DestroyHandler feature is already present or in conflict with another plugin.')

    def get_destroyers_of(r):
        (droot, impact, root_destroyer) = self.refresh_droot_impact()
        try:
            return [root_destroyer[droot[r]]]
        except Exception:
            return []
    fgraph.destroyers = get_destroyers_of
    fgraph.destroy_handler = self
    self.fgraph = attr
    self.destroyers = OrderedSet()
    self.view_i = {
        
    }
    self.view_o = {
        
    }
    self.clients = {
        
    }
    self.stale_droot = True
    if self.do_imports_on_attach:
        toolbox.Bookkeeper.on_attach(self, fgraph)

dataset/ETHPy150Open rizar/attention-lvcsr/libs/Theano/theano/gof/destroyhandler.py DestroyHandler.on_attach/VarMisuse@148/428 `fgraph`->`attr`