code: def ref_weight_normalization(w, g, dim=0, eps=1e-12):
      dim = dim + w.ndim * (dim < 0)
      axes = tuple([a for a in range(w.ndim) if a != dim])
      n = (np.sum(w**2, axes, keepdims=True) + eps) ** (-0.5)
      rshape = [1 if i != dim else s for i, s in enumerate(w.shape)]
      g = g.reshape(rshape)
      w_wn = g * w * n
      return w_wn
  
file_path: nnabla/python/test/function/test_weight_normalization.py
imports: import pytest
  import numpy
  import nnabla.functions
  from nbla_test_utils import list_context
label_desc: Use image node_id 1 for calling a global function with example usage: ref_weight_normalization(w, g, dim, eps) and returns: w_wn