def __init__(self, func):
    self.func = func
    # Note: when we're destructing the global context (i.e when the process is
    # terminating) we may have already deleted other modules. By capturing the
    # DeleteFunction function here, we retain the ability to cleanly destroy the
    # Function at shutdown, which satisfies leak checkers.
    self.deleter = c_api.TF_DeleteFunction