code: def function_network_tester(
      rng,
      func,
      inputs,
      func_args=[],
      args_out=False,
      have_scalar=False,
      backward=None,
      atol_b=1e-3,
      dstep=1e-3,
  ):
      """
      Automatic testing of backward of `func`
  
      Args:
          rng: random number generator
          func: test function name
          inputs: the inputs of func
          func_args: the other func args of func
          args_out: func_args whether contain output arguments, output arguments always set last
          have_scalar: whether the operands contain scalars
          backward: the attribute of nn.Variable
      """
  
      inputs_ = inputs
      if have_scalar:
          if args_out:
              inputs_ += func_args[:-1]
              func_args = [func_args[-1]]
          else:
              inputs_ += func_args
              func_args = []
  
      if backward is None:
          backward = [True for _ in inputs_]
  
      variable_inputs = _create_variables(inputs_, backward)
  
      # checking backward
      if False in backward:
          return
  
      # NNabla backward
      for v in variable_inputs:
          v.g = _randn(rng, *v.shape)
  
      y = func(*(variable_inputs + func_args))
      if args_out:
          y = func_args[-1]
  
      nbla_grad, numerical_grad = compute_nnabla_and_numerical_grad(
          inputs_,
          variable_inputs,
          y,
          rng,
          epsilon=dstep,
          have_scalar=have_scalar,
      )
      assert_allclose(
          nbla_grad,
          numerical_grad,
          atol=atol_b,
          err_msg="{} backward w/o accumulation test fails.".format(
              func
          ),
      )
  
file_path: nnabla/python/test/nbla_test_function_network.py
imports: import nnabla
  import numpy
  from scipy import optimize
  from nnabla.testing import assert_allclose
label_desc: Use image node_id 4 for calling a global function with example usage: function_network_tester(rng, func, inputs, func_args, args_out, have_scalar, backward, atol_b, dstep) without return types