class_docstr: Performs weight normalization.
  
  This wrapper reparameterizes a layer by decoupling the weight's
  magnitude and direction.
  This speeds up convergence by improving the
  conditioning of the optimization problem.
  
  See [Weight Normalization: A Simple Reparameterization to Accelerate Training of Deep Neural Networks](https://arxiv.org/abs/1602.07868).
  
  Wrap `tf.keras.layers.Conv2D`:
  
  >>> x = np.random.rand(1, 10, 10, 1)
  >>> conv2d = WeightNormalization(tf.keras.layers.Conv2D(2, 2), data_init=False)
  >>> y = conv2d(x)
  >>> y.shape
  TensorShape([1, 9, 9, 2])
  
  Wrap `tf.keras.layers.Dense`:
  
  >>> x = np.random.rand(1, 10, 10, 1)
  >>> dense = WeightNormalization(tf.keras.layers.Dense(10), data_init=False)
  >>> y = dense(x)
  >>> y.shape
  TensorShape([1, 10, 10, 10])
  
  Args:
    layer: A `tf.keras.layers.Layer` instance.
    data_init: If `True` use data dependent variable initialization.
  Raises:
    ValueError: If not initialized with a `Layer` instance.
    ValueError: If `Layer` does not contain a `kernel` of weights.
    NotImplementedError: If `data_init` is True and running graph execution.
docstr: Build `Layer`
docstr_tok: ["Build","`","Layer","`"]
code: def build(self, input_shape):
      """Build `Layer`"""
      input_shape = tf.TensorShape(input_shape)
      self.input_spec = tf.keras.layers.InputSpec(
          shape=[None] + input_shape[1:]
      )
  
      if not self.layer.built:
          self.layer.build(input_shape)
  
      kernel_layer = self.layer.cell if self.is_rnn else self.layer
  
      if not hasattr(kernel_layer, "kernel"):
          raise ValueError(
              "`WeightNormalization` must wrap a layer that"
              " contains a `kernel` for weights"
          )
  
      if self.is_rnn:
          kernel = kernel_layer.recurrent_kernel
      else:
          kernel = kernel_layer.kernel
  
      # The kernel's filter or unit dimension is -1
      self.layer_depth = int(kernel.shape[-1])
      self.kernel_norm_axes = list(range(kernel.shape.rank - 1))
  
      self.g = self.add_weight(
          name="g",
          shape=(self.layer_depth,),
          initializer="ones",
          dtype=kernel.dtype,
          trainable=True,
      )
      self.v = kernel
  
      self._initialized = self.add_weight(
          name="initialized",
          shape=None,
          initializer="zeros",
          dtype=tf.dtypes.bool,
          trainable=False,
      )
  
      if self.data_init:
          # Used for data initialization in self._data_dep_init.
          with tf.name_scope("data_dep_init"):
              layer_config = tf.keras.layers.serialize(self.layer)
              layer_config["config"]["trainable"] = False
              self._naked_clone_layer = tf.keras.layers.deserialize(
                  layer_config
              )
              self._naked_clone_layer.build(input_shape)
              self._naked_clone_layer.set_weights(
                  self.layer.get_weights()
              )
              if not self.is_rnn:
                  self._naked_clone_layer.activation = None
  
      self.built = True
  
file_path: addons/tensorflow_addons/layers/wrappers.py
imports: import logging
  import tensorflow
  from typeguard import typechecked
label_desc: Use image node_id 2 for calling the WeightNormalization obj's underlying member method code with example usage: obj.build(input_shape) without return types