code: def test_worker_kv_calls(monkeypatch, shutdown_only):
      monkeypatch.setenv("TEST_RAY_COLLECT_KV_FREQUENCY", "1")
      ray.init()
  
      @ray.remote
      def get_kv_metrics():
          from time import sleep
  
          sleep(2)
          return ray._private.utils._CALLED_FREQ
  
      freqs = ray.get(get_kv_metrics.remote())
      # So far we have the following gets
      """
      b'cluster' b'CLUSTER_METADATA'
      b'tracing' b'tracing_startup_hook'
      b'fun' b'IsolatedExports:01000000:\x00\x00\x00\x00\x00\x00\x00\x01'
      """
      # !!!If you want to increase this number, please let ray-core knows this!!!
      assert freqs["internal_kv_get"] == 3
  
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 6 for calling a global function with example usage: test_worker_kv_calls(monkeypatch, shutdown_only) and returns: ray