code: def test_internal_kv(ray_start_regular):
      import ray.experimental.internal_kv as kv
  
      assert kv._internal_kv_get("k1") is None
      assert kv._internal_kv_put("k1", "v1") is False
      assert kv._internal_kv_put("k1", "v1") is True
      assert kv._internal_kv_get("k1") == b"v1"
      assert kv._internal_kv_exists(b"k1") is True
      assert kv._internal_kv_exists(b"k2") is False
  
      assert kv._internal_kv_get("k1", namespace="n") is None
      assert kv._internal_kv_put("k1", "v1", namespace="n") is False
      assert kv._internal_kv_put("k1", "v1", namespace="n") is True
      assert (
          kv._internal_kv_put("k1", "v2", True, namespace="n") is True
      )
      assert kv._internal_kv_get("k1", namespace="n") == b"v2"
  
      assert kv._internal_kv_del("k1") == 1
      assert kv._internal_kv_del("k1") == 0
      assert kv._internal_kv_get("k1") is None
  
      assert kv._internal_kv_put("k2", "v2", namespace="n") is False
      assert kv._internal_kv_put("k3", "v3", namespace="n") is False
  
      assert set(kv._internal_kv_list("k", namespace="n")) == {
          b"k1",
          b"k2",
          b"k3",
      }
      assert (
          kv._internal_kv_del("k", del_by_prefix=True, namespace="n")
          == 3
      )
      assert (
          kv._internal_kv_del("x", del_by_prefix=True, namespace="n")
          == 0
      )
      assert kv._internal_kv_get("k1", namespace="n") is None
      assert kv._internal_kv_get("k2", namespace="n") is None
      assert kv._internal_kv_get("k3", namespace="n") is None
  
      with pytest.raises(ray.exceptions.RaySystemError):
          kv._internal_kv_put("@namespace_", "x", True)
      with pytest.raises(ray.exceptions.RaySystemError):
          kv._internal_kv_get("@namespace_", namespace="n")
      with pytest.raises(ray.exceptions.RaySystemError):
          kv._internal_kv_del("@namespace_def", namespace="n")
      with pytest.raises(ray.exceptions.RaySystemError):
          kv._internal_kv_list("@namespace_abc", namespace="n")
  
imports: import gc
  import logging
  import os
  import sys
  import time
  import subprocess
  from unittest.mock import Mock, patch
  import unittest
  import pytest
  import ray
  import ray.cluster_utils
  from ray._private.test_utils import run_string_as_driver, wait_for_pid_to_exit, client_test_enabled
  from ray._private.resource_spec import HEAD_NODE_RESOURCE_NAME
label_desc: Use image node_id 3 for calling a global function with example usage: test_internal_kv(ray_start_regular) without return types