code: def verify_global_avg_pool2d_grad(executor_kind, x_shape):
      x = relay.var("x", relay.TensorType(x_shape, "float32"))
      y = tvm.relay.nn.global_avg_pool2d(x)
  
      fwd_func = relay.Function([x], y)
      fwd_func = run_infer_type(fwd_func)
      bwd_func = run_infer_type(gradient(fwd_func))
  
      data = np.random.rand(*x_shape).astype("float32")
      y_shape = topi.utils.get_const_tuple(fwd_func.ret_type.shape)
      out_grad = np.ones(shape=y_shape)
      ref_grad = tvm.topi.testing.pool_grad_nchw(
          data,
          out_grad,
          pool_size=(x_shape[2], x_shape[3]),
          strides=(1, 1),
          padding=[0, 0, 0, 0],
          pool_type="avg",
          ceil_mode=False,
      )
  
      for target, dev in tvm.testing.enabled_targets():
          op_res, (op_grad,) = relay.create_executor(
              executor_kind, device=dev, target=target
          ).evaluate(bwd_func)(data)
          np.testing.assert_allclose(
              op_grad.numpy(), ref_grad, rtol=0.01
          )
  
imports: import numpy
  import pytest
  from tvm import topi
  import tvm.topi.testing
  import tvm
  from tvm import te
  from tvm import relay
  from tvm.relay.testing import check_grad, run_infer_type, run_opt_pass
  from tvm.relay.transform import gradient
  import tvm.testing
label_desc: Use image node_id 5 for calling a global function with example usage: verify_global_avg_pool2d_grad(executor_kind, x_shape) without return types