code: def dense_weightnorm(
      name, x, n_out, x_mask, init_scale, init, dtype=tf.float32
  ):
      """Dense layer with weight normalization."""
      n_in = common_layers.shape_list(x)[2]
      eps = tf.keras.backend.epsilon()
      with tf.variable_scope(name, reuse=tf.AUTO_REUSE):
          v = tf.get_variable(
              "v",
              [n_in, n_out],
              dtype,
              initializer=tf.random_normal_initializer(0, 0.05),
              trainable=True,
          )
          v = v / tf.norm(v, axis=0, keepdims=True)
          t = tf.matmul(x, v)  # [B, L, n_out]
          mean, var = moments_over_bl(t, x_mask)
          g_init = init_scale / (tf.sqrt(var) + eps)
          g = get_variable_ddi(
              "g",
              [n_out],
              g_init,
              init,
              initializer=tf.zeros_initializer,
              dtype=dtype,
              trainable=True,
          )
          b = get_variable_ddi(
              "b",
              [n_out],
              -mean * g_init,
              init,
              initializer=tf.zeros_initializer,
              dtype=dtype,
              trainable=True,
          )
          w = g * v
          y = tf.matmul(x, w) + b
          tf.summary.histogram("_g", g)
          return y
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import copy
  import math
  from tensor2tensor.layers import common_attention
  from tensor2tensor.layers import common_layers
  from tensor2tensor.models.transformer import transformer_decoder_layer
  import tensorflow.compat.v1
  import tensorflow_probability
label_desc: Use image node_id 2 for calling a global function with example usage: dense_weightnorm(name, x, n_out, x_mask, init_scale, init, dtype) and returns: y