code: def test_autoscaler_init(
      ray_start_cluster_head_with_external_redis,
  ):
      """
      Checks that autoscaler initializes properly after GCS restarts.
      """
      cluster = ray_start_cluster_head_with_external_redis
      cluster.add_node()
      cluster.wait_for_nodes()
  
      # Make sure both head and worker node are alive.
      nodes = ray.nodes()
      assert len(nodes) == 2
      assert nodes[0]["alive"] and nodes[1]["alive"]
  
      head_node = cluster.head_node
      gcs_server_process = head_node.all_processes["gcs_server"][
          0
      ].process
      gcs_server_pid = gcs_server_process.pid
      # Kill gcs server.
      cluster.head_node.kill_gcs_server()
      # Wait to prevent the gcs server process becoming zombie.
      gcs_server_process.wait()
      wait_for_pid_to_exit(gcs_server_pid, 300)
  
      # Restart gcs server process.
      cluster.head_node.start_gcs_server()
  
      from ray.autoscaler.v2.sdk import get_cluster_status
  
      status = get_cluster_status(ray.get_runtime_context().gcs_address)
      assert len(status.idle_nodes) == 2
  
imports: import sys
  import os
  import threading
  from time import sleep
  import pytest
  import ray
  from ray._private.utils import get_or_create_event_loop
  from ray.util.scheduling_strategies import PlacementGroupSchedulingStrategy
  import ray._private.gcs_utils
  from ray._private import ray_constants
  from ray._private.test_utils import convert_actor_state, enable_external_redis, generate_system_config_map, wait_for_condition, wait_for_pid_to_exit, run_string_as_driver
  from ray.job_submission import JobSubmissionClient, JobStatus
  from ray._raylet import GcsClient
  import psutil
label_desc: Use image node_id 4 for calling a global function with example usage: test_autoscaler_init(ray_start_cluster_head_with_external_redis) without return types