<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def spectral_norm(w, dim=0, itr=1, eps=1e-12, test=False, u_init=None, fix_parameters=True):
 """Spectral Normalization. .. math:: W_{sn} = \\frac{W}{\\sigma(W)}. where :math:`W` is the input matrix, and the :math:`\\sigma(W)` is the spectral norm of :math:`W`. The spectral norm is approximately computed by the power iteration. References: Takeru Miyato, Toshiki Kataoka, Masanori Koyama, Yuichi Yoshida, "Spectral Normalization for Generative Adversarial Networks", International Conference on Learning Representations. 2018. Args: W (~nnabla.Variable):
 Input N-D array with shape. This is normally network parameter. dim (`int`):
 Output dimension. Default is 0. If the dimension is not 0, then the specified dimension becomes the most-left dimension by transposing. itr (`int`):
 Number of iterations. Default is 1. eps (`float`):
 Epsilon for the normalization. Default is 1e-12. test (`bool`):
 Use test mode. Default is False. Returns: ~nnabla.Variable: Spectrally normalized :math:`W_{sn}` with the same shape as :math:`W`. Example: .. code-block:: python import nnabla as nn import nnabla.parametric_functions as PF b, c, h, w = 4, 64, 32, 32 # Spectrally normalized convolution apply_w = lambda w: PF.spectral_norm(w, dim=0) h = nn.Variable.from_numpy_array(np.random.randn(b, c, h, w)) h = PF.convolution(h, with_bias=False, apply_w=apply_w) # Spectrally normalized affine apply_w = lambda w: PF.spectral_norm(w, dim=1) h = nn.Variable.from_numpy_array(np.random.randn(b, c)) h = PF.affine(h, with_bias=False, apply_w=apply_w) # Spectrally normalized embed apply_w = lambda w: PF.spectral_norm(w, dim=1) h = nn.Variable.from_numpy_array(np.random.randn(b, c)) h = PF.embed(h, c, apply_w=apply_w) """


    assert (0 <= dim and dim < len(w.shape)
            ), "`dim` must be `0 <= dim and dim < len(w.shape)`."
    assert 0 < itr, "`itr` must be greater than 0."
    assert 0 < eps, "`eps` must be greater than 0."

    if dim == len(w.shape) - 1:
        w_sn = _spectral_norm_outer_most_dim(w, dim=dim, itr=itr, eps=eps, test=test,
                                             u_init=u_init, fix_parameters=fix_parameters)
    else:
        w_sn = _spectral_norm(w, dim=dim, itr=itr, eps=eps, test=test,
                              u_init=u_init, fix_parameters=fix_parameters)
    return w_sn