code: def test_rpc():
      if not tvm.runtime.enabled("rpc"):
          return
      # generate the wasm library
      runtime = Runtime("cpp", {"system-lib": True})
      target = "llvm -mtriple=wasm32-unknown-unknown-wasm"
      if not tvm.runtime.enabled(target):
          raise RuntimeError("Target %s is not enbaled" % target)
      n = te.var("n")
      A = te.placeholder((n,), name="A")
      B = te.compute(A.shape, lambda *i: A(*i) + 1.0, name="B")
      s = te.create_schedule(B.op)
  
      fadd = tvm.build(
          s, [A, B], target, runtime=runtime, name="addone"
      )
      temp = utils.tempdir()
  
      wasm_path = temp.relpath("addone.wasm")
      fadd.export_library(wasm_path, fcompile=emcc.create_tvmjs_wasm)
  
      wasm_binary = open(wasm_path, "rb").read()
  
      remote = rpc.connect(
          proxy_host,
          proxy_port,
          key="wasm",
          session_constructor_args=["rpc.WasmSession", wasm_binary],
      )
  
      def check(remote):
          # basic function checks.
          faddone = remote.get_function("testing.asyncAddOne")
          fecho = remote.get_function("testing.echo")
          assert faddone(100) == 101
          assert fecho(1, 2, 3) == 1
          assert fecho(1, 2, 3) == 1
          assert fecho(100, 2, 3) == 100
          assert fecho("xyz") == "xyz"
          assert bytes(fecho(bytearray(b"123"))) == b"123"
          # run the generated library.
          f1 = remote.system_lib()
          dev = remote.cpu(0)
          a = tvm.nd.array(
              np.random.uniform(size=1024).astype(A.dtype), dev
          )
          b = tvm.nd.array(np.zeros(1024, dtype=A.dtype), dev)
          # invoke the function
          addone = f1.get_function("addone")
          addone(a, b)
  
          # time evaluator
          time_f = f1.time_evaluator(
              "addone", dev, number=100, repeat=10
          )
          time_f(a, b)
          cost = time_f(a, b).mean
          print("%g secs/op" % cost)
          np.testing.assert_equal(b.numpy(), a.numpy() + 1)
  
      check(remote)
  
imports: import tvm
  from tvm import te
  from tvm import rpc
  from tvm.contrib import utils, emcc
  from tvm.relay.backend import Runtime
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: test_rpc() without return types