code: def test_random_fill():
      """Tests random_fill function"""
  
      def test_local(dev, dtype):
          if not tvm.get_global_func(
              "tvm.contrib.random.random_fill", True
          ):
              print("skip because extern function is not available")
              return
          value = tvm.nd.empty((512, 512), dtype, dev)
          random_fill = tvm.get_global_func(
              "tvm.contrib.random.random_fill"
          )
          random_fill(value)
  
          assert np.count_nonzero(value.numpy()) == 512 * 512
  
          # make sure arithmentic doesn't overflow too
          np_values = value.numpy()
          assert np.isfinite(np_values * np_values + np_values).any()
  
      def test_rpc(dtype):
          if not tvm.get_global_func(
              "tvm.contrib.random.random_fill", True
          ):
              print("skip because extern function is not available")
              return
          if not tvm.testing.device_enabled(
              "rpc"
          ) or not tvm.runtime.enabled("llvm"):
              return
  
          def check_remote(server):
              remote = rpc.connect(server.host, server.port)
              value = tvm.nd.empty((512, 512), dtype, remote.cpu())
              random_fill = remote.get_function(
                  "tvm.contrib.random.random_fill"
              )
              random_fill(value)
  
              assert np.count_nonzero(value.numpy()) == 512 * 512
  
              # make sure arithmentic doesn't overflow too
              np_values = value.numpy()
              assert np.isfinite(
                  np_values * np_values + np_values
              ).any()
  
          check_remote(rpc.Server("127.0.0.1"))
  
      for dtype in [
          "bool",
          "int4",
          "int8",
          "uint8",
          "int16",
          "uint16",
          "int32",
          "int32",
          "int64",
          "uint64",
          "float16",
          "float32",
          "float64",
      ]:
          for _, dev in tvm.testing.enabled_targets():
              test_local(dev, dtype)
          test_rpc(dtype)
  
file_path: tvm/tests/python/contrib/test_random.py
imports: import threading
  import numpy
  import tvm
  from tvm import te
  from tvm.contrib import random
  from tvm import rpc
  import tvm.testing
label_desc: Use image node_id 4 for calling a global function with example usage: test_random_fill() without return types