'Apply normalization to input.
The shape must match the declared shape in the constructor.
[This is copied from tf.contrib.rnn.LayerNormBasicLSTMCell.]
Args:
inputs: Input tensor
Returns:
Normalized version of input tensor.
Raises:
ValueError: if inputs has undefined rank.'

def normalize(self, inputs):

    inputs_shape = inputs.get_shape()
    inputs_rank = inputs_shape.ndims
    if (inputs_rank is None):
        raise ValueError(('Inputs    %s    has    undefined    rank.' % inputs.name))
    axis = range(1, inputs_rank)
    beta = self._component.get_variable(('beta_%s' % self._name))
    gamma = self._component.get_variable(('gamma_%s' % self._name))
    with tf.variable_scope(('layer_norm_%s' % self._name)):
        (mean, variance) = nn.moments(inputs, axis, keep_dims=True)
        variance_epsilon = 1e-12
        outputs = nn.batch_normalization(inputs, mean, variance, beta, gamma, variance_epsilon)
        outputs.set_shape(inputs_shape)
        return outputs
