code: def test_actor_killing(shutdown_only):
      # This is to test create and kill an actor immediately
      import ray
  
      ray.init(num_cpus=1)
  
      @ray.remote(num_cpus=1)
      class Actor:
          def foo(self):
              return None
  
      worker_1 = Actor.remote()
      ray.kill(worker_1)
      worker_2 = Actor.remote()
      assert ray.get(worker_2.foo.remote()) is None
      ray.kill(worker_2)
  
      worker_1 = Actor.options(
          max_restarts=1, max_task_retries=-1
      ).remote()
      ray.kill(worker_1, no_restart=False)
      assert ray.get(worker_1.foo.remote()) is None
  
      ray.kill(worker_1, no_restart=False)
      worker_2 = Actor.remote()
      assert ray.get(worker_2.foo.remote()) is None
  
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 2 for calling a global function with example usage: test_actor_killing(shutdown_only) and returns: None