code: def setup_multi_deployment_replicas(
      num_replicas, num_deployments
  ) -> List[str]:
      num_replica_per_deployment = num_replicas // num_deployments
      all_deployment_names = [
          f"Echo_{i+1}" for i in range(num_deployments)
      ]
  
      @serve.deployment(num_replicas=num_replica_per_deployment)
      class Echo:
          def __init__(self):
              self.all_app_async_handles = []
  
          async def get_random_async_handle(self):
              # sync get_handle() and expected to be called only a few times
              # during deployment warmup so each deployment has reference to
              # all other handles to send recursive inference call
              if len(self.all_app_async_handles) < len(
                  all_deployment_names
              ):
                  applications = list(
                      serve.status().applications.keys()
                  )
                  self.all_app_async_handles = [
                      serve.get_app_handle(app) for app in applications
                  ]
  
              return random.choice(self.all_app_async_handles)
  
          async def handle_request(self, body: bytes, depth: int):
              # Max recursive call depth reached
              if depth > 4:
                  return "hi"
  
              next_async_handle = await self.get_random_async_handle()
              fut = next_async_handle.handle_request.remote(
                  body, depth + 1
              )
  
              return await fut
  
          async def __call__(self, request: Request):
              return await self.handle_request(await request.body(), 0)
  
      for name in all_deployment_names:
          serve.run(Echo.bind(), name=name, route_prefix=f"/{name}")
  
      return all_deployment_names
  
file_path: ray/release/serve_tests/workloads/multi_deployment_1k_noop_replica.py
imports: import click
  import logging
  import math
  import random
  from typing import List, Optional
  from starlette.requests import Request
  from ray import serve
  from serve_test_utils import aggregate_all_metrics, run_wrk_on_all_nodes, save_test_results, is_smoke_test
  from serve_test_cluster_utils import setup_local_single_node_cluster, setup_anyscale_cluster, NUM_CPU_PER_NODE, NUM_CONNECTIONS
label_desc: Use image node_id 1 for calling a global function with example usage: setup_multi_deployment_replicas(num_replicas, num_deployments) and returns: all_deployment_names, random, unknown, unknown, str