class_docstr: Performs spectral normalization on weights.
  
  This wrapper controls the Lipschitz constant of the layer by
  constraining its spectral norm, which can stabilize the training of GANs.
  
  See [Spectral Normalization for Generative Adversarial Networks](https://arxiv.org/abs/1802.05957).
  
  Wrap `tf.keras.layers.Conv2D`:
  
  >>> x = np.random.rand(1, 10, 10, 1)
  >>> conv2d = SpectralNormalization(tf.keras.layers.Conv2D(2, 2))
  >>> y = conv2d(x)
  >>> y.shape
  TensorShape([1, 9, 9, 2])
  
  Wrap `tf.keras.layers.Dense`:
  
  >>> x = np.random.rand(1, 10, 10, 1)
  >>> dense = SpectralNormalization(tf.keras.layers.Dense(10))
  >>> y = dense(x)
  >>> y.shape
  TensorShape([1, 10, 10, 10])
  
  Args:
    layer: A `tf.keras.layers.Layer` instance that
      has either `kernel` or `embeddings` attribute.
    power_iterations: `int`, the number of iterations during normalization.
  Raises:
    AssertionError: If not initialized with a `Layer` instance.
    ValueError: If initialized with negative `power_iterations`.
    AttributeError: If `layer` does not has `kernel` or `embeddings` attribute.
docstr: Build `Layer`
code: def build(self, input_shape):
      """Build `Layer`"""
      super().build(input_shape)
      input_shape = tf.TensorShape(input_shape)
      self.input_spec = tf.keras.layers.InputSpec(
          shape=[None] + input_shape[1:]
      )
  
      if hasattr(self.layer, "kernel"):
          self.w = self.layer.kernel
      elif hasattr(self.layer, "embeddings"):
          self.w = self.layer.embeddings
      else:
          raise AttributeError(
              "{} object has no attribute 'kernel' nor "
              "'embeddings'".format(type(self.layer).__name__)
          )
  
      self.w_shape = self.w.shape.as_list()
  
      self.u = self.add_weight(
          shape=(1, self.w_shape[-1]),
          initializer=tf.initializers.TruncatedNormal(stddev=0.02),
          trainable=False,
          name="sn_u",
          dtype=self.w.dtype,
      )
  
file_path: addons/tensorflow_addons/layers/spectral_normalization.py
imports: import tensorflow
  from typeguard import typechecked
label_desc: Use image node_id 2 for calling the SpectralNormalization obj's underlying member method code with example usage: obj.build(input_shape) without return types