code: def test_runtime_env_hook(skip_hook):
      ray_init_snippet = (
          "ray.init(_skip_env_hook=True)" if skip_hook else ""
      )
  
      script = f"""
  import ray
  import os
  
  {ray_init_snippet}
  
  @ray.remote
  def f():
      return os.environ.get("HOOK_KEY")
  
  print(ray.get(f.remote()))
  """
  
      proc = run_string_as_driver_nonblocking(
          script,
          env={"RAY_RUNTIME_ENV_HOOK": "ray.tests.test_output._hook"},
      )
      out_str = proc.stdout.read().decode(
          "ascii"
      ) + proc.stderr.read().decode("ascii")
      print(out_str)
      if skip_hook:
          assert "HOOK_VALUE" not in out_str
      else:
          assert "HOOK_VALUE" in out_str
  
imports: import os
  import re
  import signal
  import subprocess
  import sys
  import time
  import pytest
  import ray
  from ray._private.test_utils import run_string_as_driver, run_string_as_driver_nonblocking, wait_for_condition
label_desc: Use image node_id 6 for calling a global function with example usage: test_runtime_env_hook(skip_hook) without return types