code: def test_kill_actor_gcs(ray_start_with_dashboard):
      # Start the dashboard
      webui_url = ray_start_with_dashboard["webui_url"]
      assert wait_until_server_available(webui_url)
      webui_url = format_web_url(webui_url)
  
      @ray.remote
      class Actor:
          def f(self):
              ray._private.worker.show_in_dashboard("test")
              return os.getpid()
  
          def loop(self):
              while True:
                  time.sleep(1)
                  print("Looping...")
  
      # Create an actor
      a = Actor.remote()
      worker_pid = ray.get(a.f.remote())  # noqa
      actor_id = a._ray_actor_id.hex()
  
      # Kill the actor
      _kill_actor_using_dashboard_gcs(
          webui_url, actor_id, force_kill=False
      )
      assert _actor_killed_loop(worker_pid)
  
      # Create an actor and have it loop
      a = Actor.remote()
      worker_pid = ray.get(a.f.remote())  # noqa
      actor_id = a._ray_actor_id.hex()
      a.loop.remote()
  
      # Try to kill the actor, it should not die since a task is running
      _kill_actor_using_dashboard_gcs(
          webui_url, actor_id, force_kill=False
      )
      assert not _actor_killed_loop(worker_pid, timeout_secs=1)
  
      # Force kill the actor
      _kill_actor_using_dashboard_gcs(
          webui_url, actor_id, force_kill=True
      )
      assert _actor_killed_loop(worker_pid)
  
file_path: ray/dashboard/modules/snapshot/tests/test_actors.py
imports: import logging
  import os
  import sys
  import time
  import pytest
  import requests
  import ray
  from ray._private.test_utils import format_web_url, wait_until_server_available
  from ray.dashboard.tests.conftest import *
label_desc: Use image node_id 4 for calling a global function with example usage: test_kill_actor_gcs(ray_start_with_dashboard) and returns: os