code: def test_pf_spectral_norm_execution(
      g_rng, w_shape, dim, itr, test, u_init
  ):
      # python implementation
      def spectral_norm_numpy(
          w, dim=0, itr=1, eps=1e-12, u_init_d=None
      ):
          w_shape = w.shape
          if dim != 0:
              dims_transpose = [dim] + [
                  i for i in range(len(w_shape)) if i != dim
              ]
              w = w.transpose(*dims_transpose)
              w_shape = w.shape
          d0, d1 = w_shape[0], np.prod(w_shape[1:])  # [Out, In]
          w = w.reshape((d0, d1))
          u = u_init_d
          for i in range(itr):
              v = np.dot(w.T, u)
              v = v / np.sqrt(np.sum(v**2) + eps)
              u = np.dot(w, v)
              u = u / np.sqrt(np.sum(u**2) + eps)
          sigma = np.dot(u.T, np.dot(w, v))
          w_sn = w / sigma
          w_sn = w_sn.reshape(w_shape)
          if dim != 0:
              dims_transpose = (
                  [i for i in range(1, dim + 1)]
                  + [0]
                  + [i for i in range(dim + 1, len(w_shape))]
              )
              w_sn = w_sn.transpose(*dims_transpose)
          return w_sn
  
      # Setting
      w = nn.Variable.from_numpy_array(g_rng.randn(*w_shape))
      u_init = process_param_init(u_init, [w_shape[dim]], g_rng)
  
      # Check execution
      w_sn = PF.spectral_norm(w, dim, itr, test=test, u_init=u_init)
      u_init_d = (
          nn.get_parameters(grad_only=False)["spectral-norm/u"].d.copy()
          if u_init is None
          else u_init
      )
  
      w_sn.forward()
      w_sn.backward()
  
      # Check values
      w_sn_numpy = spectral_norm_numpy(w.d, dim, itr, u_init_d=u_init_d)
      assert_allclose(w_sn_numpy, w_sn.d, atol=1e-2, rtol=1e-5)
      if test:
          u = nn.get_parameters(grad_only=False)["spectral-norm/u"]
          assert_allclose(u_init_d, u.d)
  
      # Check args (cannot since this is the functions composite)
  
      # Check created parameters
      assert len(nn.get_parameters(grad_only=False)) == 1
      u = nn.get_parameters(grad_only=False)["spectral-norm/u"]
  
imports: import pytest
  import numpy
  import nnabla
  import nnabla.functions
  import nnabla.parametric_functions
  import nnabla.initializer
  from nnabla.testing import assert_allclose
  from nbla_test_utils import list_context
label_desc: Use image node_id 15 for calling a global function with example usage: test_pf_spectral_norm_execution(g_rng, w_shape, dim, itr, test, u_init) and returns: w_sn