code: def test_shared_leaf_variable_basic_arithmetics(
      seed, ctx, auto_forward
  ):
      def add(x, derivative=0):
          if derivative == 0:
              return x + x + x
          if derivative == 1:
              return 3 * np.ones_like(x)
          if derivative == 2:
              return np.zeros_like(x)
  
      def sub(x, derivative=0):
          if derivative == 0:
              return x - x - x
          if derivative == 1:
              return -1 * np.ones_like(x)
          if derivative == 2:
              return np.zeros_like(x)
  
      def mul(x, derivative=0):
          if derivative == 0:
              return x * x * x
          if derivative == 1:
              return 3 * x**2
          if derivative == 2:
              return 6 * x
  
      def div(x, derivative=0):
          if derivative == 0:
              return x / x / x
          if derivative == 1:
              return -(x**-2)
          if derivative == 2:
              return 2 * x**-3
  
      # Settings
      nn.set_default_context(ctx)
      nn.set_auto_forward(auto_forward)
  
      for math_type in [add, sub, mul, div]:
          xd = np.random.randn(2, 3) + 0.5
          x = nn.Variable.from_numpy_array(xd).apply(need_grad=True)
          x.grad.zero()
          y = math_type(x)
          # First-order gradient
          dy_dx = nn.grad([y], [x])
          if not auto_forward:
              dy_dx[0].forward()
          assert_allclose(dy_dx[0].d, math_type(xd, 1))
          # Second-order gradient
          dy_dx[0].backward()
          assert_allclose(x.g, math_type(xd, 2))
  
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 6 for calling a global function with example usage: test_shared_leaf_variable_basic_arithmetics(seed, ctx, auto_forward) and returns: unknown, unknown, np, unknown, unknown, np, unknown, unknown, unknown, unknown, unknown, unknown