code: def test_unhealthy_retry_correct_number_of_times():
      """Test the unhealthy retry logic retries the correct number of times.
  
      When the health check fails 3 times (default retry threshold), the proxy state
      should change from HEALTHY to UNHEALTHY.
      """
  
      proxy_state = _create_proxy_state()
      proxy_state._actor_proxy_wrapper.health = (
          ProxyWrapperCallStatus.PENDING
      )
  
      # Trigger update once. The status should change from STARTING to HEALTHY
      proxy_state.update()
      assert proxy_state.status == ProxyStatus.HEALTHY
  
      # 3 consecutive failures should trigger the proxy state to be UNHEALTHY
      def proxy_state_consecutive_health_check_failures(num_failures):
          proxy_state.update()
          assert (
              proxy_state._consecutive_health_check_failures
              == num_failures
          )
          return True
  
      wait_for_condition(
          condition_predictor=proxy_state_consecutive_health_check_failures,
          num_failures=3,
      )
  
      assert proxy_state.status == ProxyStatus.UNHEALTHY
  
imports: import json
  import time
  from typing import List, Tuple
  from unittest.mock import patch
  import pytest
  from ray._private.test_utils import wait_for_condition
  from ray.serve._private.cluster_node_info_cache import ClusterNodeInfoCache
  from ray.serve._private.common import ProxyStatus
  from ray.serve._private.constants import PROXY_HEALTH_CHECK_UNHEALTHY_THRESHOLD
  from ray.serve._private.proxy_state import ProxyState, ProxyStateManager, ProxyWrapper, ProxyWrapperCallStatus
  from ray.serve._private.test_utils import MockTimer
  from ray.serve._private.utils import Timer
  from ray.serve.config import DeploymentMode, HTTPOptions
  from ray.serve.schema import LoggingConfig
label_desc: Use image node_id 20 for calling a global function with example usage: test_unhealthy_retry_correct_number_of_times() and returns: True