code: def test_mean_subtraction_forward_backward(
      seed, inshape, base_axis, ctx, func_name
  ):
      from nbla_test_utils import function_tester
  
      rng = np.random.RandomState(seed)
      mean_shape = (
          inshape[base_axis:]
          if base_axis >= 0
          else inshape[base_axis + len(inshape) :]
      )
      inputs = [
          np.array(rng.randn(*inshape).astype(np.float32)),
          np.zeros(mean_shape),
          np.array([1000]),
      ]
      batch_stat = True
  
      function_tester(
          rng,
          F.mean_subtraction,
          ref_mean_subtraction,
          inputs,
          func_args=[base_axis, batch_stat],
          ctx=ctx,
          func_name=func_name,
          dstep=1e-2,
          backward=[True, False, False],
          atol_b=1e-2,
      )
  
      # Check if running mean works.
      vinputs = []
      for input in inputs:
          vinputs.append(nn.Variable(input.shape, True))
          vinputs[-1].d = input
      for i in range(5):
          inputs[0] = rng.randn(*inputs[0].shape)
          vinputs[0].d[...] = inputs[0]
          ref_y, rmean = ref_mean_subtraction(
              *(inputs + [base_axis, batch_stat])
          )
          with nn.auto_forward():
              y = F.mean_subtraction(
                  *(vinputs + [base_axis, batch_stat])
              )
          # print('vinput[1].d', vinputs[1].d, vinputs[2].d)
          # print('inputs[1]', inputs[1], inputs[2])
          assert_allclose(vinputs[1].d, inputs[1])
  
      # Check if global stat mode works
      batch_stat = False
      ref_y = ref_mean_subtraction(*(inputs + [base_axis, batch_stat]))
      with nn.auto_forward():
          y = F.mean_subtraction(*(vinputs + [base_axis, batch_stat]))
      assert_allclose(ref_y, y.d)
  
file_path: nnabla/python/test/function/test_mean_subtraction.py
imports: import pytest
  import numpy
  import nnabla
  import nnabla.functions
  from nbla_test_utils import list_context
  from nnabla.testing import assert_allclose
label_desc: Use image node_id 2 for calling a global function with example usage: test_mean_subtraction_forward_backward(seed, inshape, base_axis, ctx, func_name) without return types