import tensorflow as tf


    if decoder.use_lstm is False:
        decoder.cell_type = 'GRU'

    embedding_shape = [decoder.vocab_size, decoder.embedding_size]
    weight_scale = decoder.embedding_weight_scale or decoder.weight_scale
    if weight_scale is None:
        initializer = None  # FIXME
    elif decoder.embedding_initializer == 'uniform' or (decoder.embedding_initializer is None
                                                        and decoder.initializer == 'uniform'):
        initializer = tf.random_uniform_initializer(minval=-weight_scale, maxval=weight_scale)
    else:
        initializer = tf.random_normal_initializer(stddev=weight_scale)

    with tf.device('/cpu:0'):
        embedding = get_variable('embedding_{}'.format(decoder.name), shape=embedding_shape, initializer=initializer)

    input_shape = tf.shape(decoder_inputs)
    batch_size = input_shape[0]
    time_steps = input_shape[1]

    scope_name = 'decoder_{}'.format(decoder.name)
    scope_name += '/' + '_'.join(encoder.name for encoder in encoders)

    def embed(input_):
        embedded_input = tf.nn.embedding_lookup(embedding, input_)

        if decoder.use_dropout and decoder.word_keep_prob is not None:
