

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        Give the FunctionGraph instance:\n            1) A new method "destroyers(var)"\n               TODO: what does this do exactly?\n            2) A new attribute, "destroy_handler"\n        TODO: WRITEME: what does this do besides the checks?\n\n        '
    already_there = False
    if (self.fgraph is fgraph):
        already_there = True
    if (self.fgraph is not None):
        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.')
    self.unpickle(fgraph)
    fgraph.destroy_handler = self
    self.fgraph = fgraph
    self.destroyers = OrderedSet()
    self.view_i = OrderedDict()
    self.view_o = OrderedDict()
    self.clients = OrderedDict()
    self.stale_droot = True
    self.debug_all_apps = OrderedSet()
    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/original