code: def test_where(executor_kind):
      def run(func, inputs, ref_res):
          for target, dev in tvm.testing.enabled_targets():
              op_res = relay.create_executor(
                  executor_kind, device=dev, target=target
              ).evaluate(func)(*inputs)
              tvm.testing.assert_allclose(
                  op_res.numpy(), ref_res, rtol=1e-5
              )
  
      def verify(x_np, y_np, cond_np):
          ref_res = np.where(cond_np, x_np, y_np)
  
          args = []
          args_np = []
          vs = []
  
          cond = relay.var(
              "cond", relay.TensorType(cond_np.shape, "bool")
          )
  
          args.append(cond)
          args_np.append(cond_np)
  
          for v_name, v_np in [("x", x_np), ("y", y_np)]:
              if len(v_np.shape) == 0:
                  v = relay.const(v_np.item())
              else:
                  v = relay.var(
                      v_name, relay.TensorType(v_np.shape, dtype)
                  )
                  args.append(v)
                  args_np.append(v_np)
              vs.append(v)
  
          z = relay.where(cond, vs[0], vs[1])
  
          func = relay.Function(args, z)
  
          run(func, args_np, ref_res)
  
      dtype = "float32"
  
      x_np = np.random.uniform(size=(3, 4)).astype(dtype)
      y_np = np.random.uniform(size=(3, 4)).astype(dtype)
      cond_np = np.random.uniform(low=-1, high=1, size=(3, 4)) > 0
  
      verify(x_np, y_np, cond_np)
  
      x_np = np.array(1.0, dtype)
      y_np = np.array(-1.0, dtype)
      cond_np = np.array([1, 0, 1], dtype=bool)
  
      verify(x_np, y_np, cond_np)
  
      x_np = np.arange(10).astype(dtype)
      y_np = 10 * x_np
      cond_np = x_np < 5
  
      verify(x_np, y_np, cond_np)
  
      x_np = np.array([[1, 2], [3, 4]], dtype)
      y_np = np.array([[5, 6], [7, 8]], dtype)
      cond_np = np.array([[1], [0]], dtype=bool)
  
      verify(x_np, y_np, cond_np)
      verify(x_np, y_np, cond_np.T)
  
      x_np = np.random.randn(1, 12, 8, 8).astype(dtype)
      y_np = np.array(-1.0, dtype)
      cond_np = np.random.randn(1, 1, 8, 8) > 0
  
      verify(x_np, y_np, cond_np)
  
      x_np, y_np = np.ogrid[:3, :4]
      cond_np = np.where(x_np < y_np, x_np, 10 + y_np).astype(bool)
  
      verify(x_np.astype(dtype), y_np.astype(dtype), cond_np)
  
imports: import sys
  import numpy
  import numpy.random
  import pytest
  import tvm
  import tvm.testing
  import tvm.topi.testing
  from tvm import relay, te
  from tvm.relay import transform
  from tvm.relay.testing import run_infer_type
label_desc: Use image node_id 5 for calling a global function with example usage: test_where(executor_kind) without return types