code: def test_pf_instance_normalization(
      g_rng,
      inshape,
      batch_axis,
      channel_axis,
      output_stat,
      fix_parameters,
      param_init,
      no_scale,
      no_bias,
  ):
      from nnabla.normalization_functions import (
          _force_list,
          _get_axes_excluding,
          _apply_affine,
      )
  
      def ref_instance_normalization(
          x, beta, gamma, channel_axis, batch_axis, eps, output_stat
      ):
          ignore_axes = _force_list(batch_axis) + [
              channel_axis,
          ]
  
          axes = tuple(_get_axes_excluding(len(x.shape), ignore_axes))
  
          x_mean = x.mean(axis=axes, keepdims=True)
          x_var = x.var(axis=axes, keepdims=True)
  
          norm = (x - x_mean) / (x_var + eps) ** 0.5
  
          if no_scale:
              gamma = None
  
          if no_bias:
              beta = None
  
          if output_stat:
              return (
                  _apply_affine(norm, scale=gamma, bias=beta),
                  x_mean,
                  x_var,
              )
  
          return _apply_affine(norm, scale=gamma, bias=beta)
  
      eps = 1e-5
  
      p_shape = [1 for _ in range(len(inshape))]
      p_shape[channel_axis] = inshape[channel_axis]
      p_shape = tuple(p_shape)
  
      x_npy = g_rng.randn(*inshape).astype(np.float32)
  
      if param_init:
          beta_init = np.ones(p_shape)
          gamma_init = np.ones(p_shape) * 2
          param_init = dict(beta=beta_init, gamma=gamma_init)
      else:
          beta_init = np.zeros(p_shape)
          gamma_init = np.ones(p_shape)
  
      x = nn.Variable.from_numpy_array(x_npy)
  
      kw = {}
      insert_if_not_default(kw, "channel_axis", channel_axis, 1)
      insert_if_not_default(kw, "batch_axis", batch_axis, 0)
      insert_if_not_default(kw, "eps", eps, 1e-5)
      insert_if_not_default(kw, "output_stat", output_stat, False)
      insert_if_not_default(kw, "fix_parameters", fix_parameters, False)
      insert_if_not_none(kw, "param_init", param_init)
      kw.update({"no_scale": no_scale, "no_bias": no_bias})
  
      # Check creation
      y = PF.instance_normalization(x, **kw)
      y = _force_list(y)  # just to simplify after execution
  
      # Check execution
      forward_backward_all(*y)
  
      # Check values
      ref = ref_instance_normalization(
          x_npy,
          beta_init,
          gamma_init,
          channel_axis,
          batch_axis,
          eps,
          output_stat,
      )
      if not output_stat:
          ref = [ref]
  
      for i in range(len(ref)):
          assert_allclose(y[i].d, ref[i], atol=1e-2, rtol=1e-5)
  
      # Check created parameters
      check_normalization_params(
          "instance_normalization",
          p_shape,
          gamma_init,
          beta_init,
          no_scale,
          no_bias,
      )
  
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 18 for calling a global function with example usage: test_pf_instance_normalization(g_rng, inshape, batch_axis, channel_axis, output_stat, fix_parameters, param_init, no_scale, no_bias) and returns: _apply_affine, _apply_affine,  x_mean,  x_var