code: def test_grad_grad_resnet(seed, ctx, auto_forward, inplace, shared):
      backend = ctx.backend[0].split(":")[0]
      if backend == "cuda":
          pytest.skip(
              "CUDA Convolution N-D is only supported in CUDNN extension"
          )
  
      if (
          sys.version_info[1] >= 9
          and auto_forward == True
          and shared == False
      ):
          pytest.skip(
              "Skip to avoid random KeyError with _ModuleLock. Referred to nnabla-ext-cuda issue #481."
          )
  
      nn.clear_parameters()
  
      # Settings
      nn.set_default_context(ctx)
      nn.set_auto_forward(auto_forward)
      b, c, h, w = 4, 3, 32, 32
      n_cls = 10
      rng = np.random.RandomState(seed)
  
      # Network
      x = nn.Variable.from_numpy_array(rng.randn(b, c, h, w)).apply(
          need_grad=True
      )
      y = SmallResNet(x, inplace=inplace, shared=shared)
  
      # Grad of grad
      dx = nn.grad([y], [x])
      ddx = nn.grad([dx[0]], [x])
      ddx[0].forward() if not auto_forward else None
      # Backward of grad
      x.grad.zero()
      dx[0].forward() if not auto_forward else None
      dx[0].backward()
  
      # Check between results of var.backward and nn.grad
      assert_allclose(x.g, ddx[0].d, atol=1e-6)
  
imports: import sys
  import pytest
  import numpy
  import nnabla
  import nnabla.functions
  import nnabla.parametric_functions
  import nnabla.initializer
  from nnabla.ext_utils import get_extension_context
  from nbla_test_utils import list_context
  from nnabla.testing import assert_allclose
  from nnabla.function import PythonFunction
  from nnabla.backward_functions import registry, register
label_desc: Use image node_id 3 for calling a global function with example usage: test_grad_grad_resnet(seed, ctx, auto_forward, inplace, shared) without return types