def keras_clip(optimizer):
    """ Convenience function for creating kwargs for setting Keras gradient
		clipping.
	"""
    if optimizer.clip_type is None:
        return {}
    elif optimizer.clip_type == 'norm':
        return {'clipnorm': optimizer.clip_value}
    elif optimizer.clip_type == 'abs':
        return {'clipvalue': optimizer.clip_value}
    else:
        raise ValueError('Unhandled clip type: {}. This is a bug.'.format(
            optimizer.clip_type))
