code: def verify_conv2d_backward_weight(
      executor_kind,
      dy_shape,
      x_shape,
      kernel_size,
      stride,
      padding,
      groups=1,
      out_channels=None,
  ):
      dtype = "float32"
      dy = relay.var("dy", shape=dy_shape, dtype=dtype)
      x = relay.var("x", shape=x_shape, dtype=dtype)
      dw_func = relay.Function(
          [dy, x],
          relay.nn.conv2d_backward_weight(
              dy,
              x,
              strides=stride,
              padding=padding,
              kernel_size=kernel_size,
              groups=groups,
              channels=out_channels,
              out_dtype=dtype,
          ),
      )
  
      dw_func_legalized = run_opt_pass(
          dw_func, relay.transform.Legalize()
      )
  
      for dw, target in [
          (dw_func_legalized, "llvm"),
          (dw_func, "cuda -libs=cudnn"),
      ]:
          if "cudnn" in target and not tvm.contrib.cudnn.exists():
              continue
  
          dev = tvm.device(target, 0)
          dy_np = np.random.randn(*dy_shape).astype(dtype)
          x_np = np.random.randn(*x_shape).astype(dtype)
  
          dw_np = (
              relay.create_executor(
                  executor_kind, device=dev, target=target
              )
              .evaluate(dw)(dy_np, x_np)
              .numpy()
          )
          ref_dw_np = tvm.topi.testing.conv2d_backward_weight_python(
              dy_np,
              x_np,
              kernel_size,
              stride,
              padding,
              groups=groups,
              channels=out_channels,
          )
  
          np.testing.assert_allclose(
              dw_np, ref_dw_np, rtol=1e-4, atol=1e-4
          )
  
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 15 for calling a global function with example usage: verify_conv2d_backward_weight(executor_kind, dy_shape, x_shape, kernel_size, stride, padding, groups, out_channels) without return types