def change_flags(**kwargs):
    def change_flags_exec(f):
        def inner(*args, **kwargs_):
            old_val = {}
            for k in kwargs:
                l = [v for v in theano.configparser._config_var_list
                     if v.fullname == k]
                assert len(l) == 1
                old_val[k] = l[0].__get__(True, None)
            try:
                for k in kwargs:
                    l = [v for v in theano.configparser._config_var_list
                         if v.fullname == k]
                    assert len(l) == 1
                    l[0].__set__(None, kwargs[k])
                return f(*args, **kwargs_)
            finally:
                for k in kwargs:
                    l = [v for v in theano.configparser._config_var_list
                         if v.fullname == k]
                    assert len(l) == 1
                    l[0].__set__(None, old_val[k])

        # Make sure that the name of the decorated function remains the same.
        inner.__name__ = f.__name__

        return inner
    return change_flags_exec
Use this as a decorator to change the value of Theano config variable.
dataset/ETHPy150Open rizar/attention-lvcsr/libs/Theano/theano/configparser.py/change_flags