code: def test_graph_clear_buffer(seed):
      np.random.seed(313)
      rng = np.random.RandomState(seed)
      x = nn.Variable([2, 3, 4, 4])
      t = nn.Variable([2, 1])
      x.d = rng.randn(*x.shape)
      t.d = rng.randint(0, 5, size=t.shape)
  
      # Network definition
      nn.set_default_context(nn.Context())
      nn.clear_parameters()
      x1 = x + 1
      x2 = x1 - 1
      with nn.parameter_scope("conv1"):
          z = PF.convolution(x2, 3, (2, 2))
          z2 = F.relu(z, inplace=True)
      with nn.parameter_scope("fc2"):
          z3 = PF.affine(z2, 5)
          z4 = PF.affine(z2, 5)
      l1 = F.softmax_cross_entropy(z3, t, 1)
      L1 = F.mean(l1)
      l2 = F.softmax_cross_entropy(z4, t, 1)
      L2 = F.mean(l2)
  
      # Forwardprop
      import tempfile
      import os
  
      tmpd = tempfile.mkdtemp()
      nn.save_parameters(os.path.join(tmpd, "parameter.h5"))
      first = False
      for cnng in [False, True]:
          for cb in [False, True]:
              _ = nn.load_parameters(os.path.join(tmpd, "parameter.h5"))
              for v in nn.get_parameters().values():
                  v.grad.zero()
              nn.forward_all([L1, L2], clear_no_need_grad=cnng)
  
              # for now, the first backward cannot be
              # called with clear_buffer=True
              L1.backward(clear_buffer=False)
              L2.backward(clear_buffer=cb)
              if not first:
                  first = True
                  g = list(nn.get_parameters().values())[0].g.copy()
              else:
                  g2 = list(nn.get_parameters().values())[0].g.copy()
                  import platform
  
                  if platform.machine() == "ppc64le":
                      pytest.skip("This test fails on ppc64le")
                  assert np.all(g == g2)
  
file_path: nnabla/python/test/test_forward_all.py
imports: from six.moves import range
  import pytest
  import numpy
  import nnabla
  import nnabla.functions
  import nnabla.parametric_functions
  from nnabla.testing import assert_allclose
label_desc: Use image node_id 5 for calling a global function with example usage: test_graph_clear_buffer(seed) without return types