def set_keras_backend(backend=None, gpu_device_nums=None, num_threads=None):
os.environ["<STR_LIT>"] = "<STR_LIT>"<EOL>original_backend = backend<EOL>if not backend:<EOL><INDENT>backend = "<STR_LIT>"<EOL><DEDENT>if gpu_device_nums is not None:<EOL><INDENT>os.environ["<STR_LIT>"] = "<STR_LIT:U+002C>".join(<EOL>[str(i) for i in gpu_device_nums])<EOL><DEDENT>if backend == "<STR_LIT>" or gpu_device_nums == []:<EOL><INDENT>print("<STR_LIT>")<EOL>os.environ["<STR_LIT>"] = "<STR_LIT>"<EOL>device_count = {'<STR_LIT>': <NUM_LIT:1>, '<STR_LIT>': <NUM_LIT:0>}<EOL><DEDENT>elif backend == "<STR_LIT>":<EOL><INDENT>print("<STR_LIT>")<EOL>device_count = {'<STR_LIT>': <NUM_LIT:0>, '<STR_LIT>': <NUM_LIT:1>}<EOL><DEDENT>elif backend == "<STR_LIT>":<EOL><INDENT>print("<STR_LIT>")<EOL>device_count = None<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>" % backend)<EOL><DEDENT>import tensorflow<EOL>from keras import backend as K<EOL>if K.backend() == '<STR_LIT>':<EOL><INDENT>config = tensorflow.ConfigProto(device_count=device_count)<EOL>config.gpu_options.allow_growth = True<EOL>if num_threads:<EOL><INDENT>config.inter_op_parallelism_threads = num_threads<EOL>config.intra_op_parallelism_threads = num_threads<EOL><DEDENT>session = tensorflow.Session(config=config)<EOL>K.set_session(session)<EOL><DEDENT>else:<EOL><INDENT>if original_backend or gpu_device_nums or num_threads:<EOL><INDENT>warnings.warn(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % K.backend())<EOL><DEDENT><DEDENT>
Configure Keras backend to use GPU or CPU. Only tensorflow is supported.

Parameters
----------
backend : string, optional
    one of 'tensorflow-default', 'tensorflow-cpu', 'tensorflow-gpu'

gpu_device_nums : list of int, optional
    GPU devices to potentially use

num_threads : int, optional
    Tensorflow threads to use