code: def test_named_actor_cache(ray_start_regular_shared):
      """Verify that named actor cache works well."""
  
      @ray.remote(max_restarts=-1)
      class Counter:
          def __init__(self):
              self.count = 0
  
          def inc_and_get(self):
              self.count += 1
              return self.count
  
      a = Counter.options(name="hi").remote()
      first_get = ray.get_actor("hi")
      assert ray.get(first_get.inc_and_get.remote()) == 1
      second_get = ray.get_actor("hi")
      assert ray.get(second_get.inc_and_get.remote()) == 2
      ray.kill(a, no_restart=True)
  
      def actor_removed():
          try:
              ray.get_actor("hi")
              return False
          except ValueError:
              return True
  
      wait_for_condition(actor_removed)
  
      get_after_restart = Counter.options(name="hi").remote()
      assert ray.get(get_after_restart.inc_and_get.remote()) == 1
      get_by_name = ray.get_actor("hi")
      assert ray.get(get_by_name.inc_and_get.remote()) == 2
  
imports: import datetime
  import os
  import random
  import sys
  import tempfile
  import numpy
  import pytest
  import ray
  from ray import cloudpickle
  from ray._private import ray_constants
  from ray._private.test_utils import client_test_enabled, wait_for_condition, wait_for_pid_to_exit
  from ray.actor import ActorClassInheritanceException
  from ray.tests.client_test_utils import create_remote_signal_actor
  from ray._private.test_utils import SignalActor
  import setproctitle
label_desc: Use image node_id 36 for calling a global function with example usage: test_named_actor_cache(ray_start_regular_shared) and returns: self, False, True