code: def test_preload_workers(ray_start_cluster, preload):
      """
      Verify preload_python_modules actually preloads modules in the Ray workers.
      Also verify that it does not crash if a non-existent module is provided.
      """
      cluster = ray_start_cluster
  
      # Specifying imports not currently imported by default_worker.py
      expect_succeed_imports = ["html.parser", "webbrowser"]
      expect_fail_imports = ["fake_module_expect_ModuleNotFoundError"]
  
      if preload:
          cluster.add_node(
              _system_config={
                  "preload_python_modules": [
                      *expect_succeed_imports,
                      *expect_fail_imports,
                  ]
              }
          )
      else:
          cluster.add_node()
  
      @ray.remote(num_cpus=0)
      class Latch:
          """
          Used to ensure two separate worker processes.
          """
  
          def __init__(self, count):
              self.count = count
  
          def decr(self):
              self.count -= 1
  
          def is_ready(self):
              return self.count <= 0
  
      def wait_latch(latch):
          latch.decr.remote()
          while not ray.get(latch.is_ready.remote()):
              time.sleep(0.01)
  
      def assert_correct_imports():
          import sys
  
          imported_modules = set(sys.modules.keys())
  
          if preload:
              for expected_import in expect_succeed_imports:
                  assert (
                      expected_import in imported_modules
                  ), f"Expected {expected_import} to be in {imported_modules}"
              for unexpected_import in expect_fail_imports:
                  assert (
                      unexpected_import not in imported_modules
                  ), f"Expected {unexpected_import} to not be in {imported_modules}"
          else:
              for unexpected_import in expect_succeed_imports:
                  assert (
                      unexpected_import not in imported_modules
                  ), f"Expected {unexpected_import} to not be in {imported_modules}"
  
      @ray.remote(num_cpus=0)
      class Actor:
          def verify_imports(self, latch):
              wait_latch(latch)
              assert_correct_imports()
  
      @ray.remote(num_cpus=0)
      def verify_imports(latch):
          wait_latch(latch)
          assert_correct_imports()
  
      latch = Latch.remote(2)
      actor = Actor.remote()
      futures = [
          verify_imports.remote(latch),
          actor.verify_imports.remote(latch),
      ]
      ray.get(futures)
  
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 8 for calling a global function with example usage: test_preload_workers(ray_start_cluster, preload) and returns: unknown