'In addition to standard gradient clipping, also clips embedding
gradients to a specified value.'

def _clip_gradients(self, grads_and_vars):

    grads_and_vars = super(Seq2SeqModel, self)._clip_gradients(grads_and_vars)
    clipped_gradients = []
    variables = []
    for (gradient, variable) in grads_and_vars:
        if (u'embedding' in variable.name):
            tmp = tf.clip_by_norm(gradient.values, self.params[u'optimizer.clip_embed_gradients'])
            gradient = tf.IndexedSlices(tmp, gradient.indices, gradient.dense_shape)
        clipped_gradients.append(gradient)
        variables.append(variable)
    return list(zip(clipped_gradients, variables))
