human
I wrote the below code

    from tensorflow.contrib import graph_editor as ge
    def make_initializer(var):
        def f():
            return tf.assign(var, var.initial_value).op
        return f
    def make_noop():
        return tf.no_op()
    def make_safe_initializer(var):
        'Returns    initializer    op    that    only    runs    for    uninitialized    ops.'
        return tf.cond(tf.is_variable_initialized(var), make_noop, make_initializer(var), name=('safe_init_' + var.op.name)).op
    if (not sess):
        sess = tf.get_default_session()
    g = tf.get_default_graph()
    if (not variables):
        variables = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES)
    safe_initializers = {}
    for v in variables:
        safe_initializers[v.op.name] = make_safe_initializer(v)
    for v in variables:
        var_name = v.op.name
        var_cache = g.get_operation_by_name((var_name + '/read'))
        ge.reroute.add_control_inputs(var_cache, [safe_initializers[var_name]])
    sess.run(tf.group(*safe_initializers.values()))
    for v in variables:
        var_name = v.op.name
        var_cache = g.get_operation_by_name((var_name + '/read'))
        ge.reroute.remove_control_inputs(var_cache, [safe_initializers[var_name]])

What's a good function header?
 ... Here's a good function header?
assistant
#Here's a good function header.

def smart_initialize(variables=None, sess=None):