code: def test_gradio_ingress_scaling(serve_start_shutdown):
      """
      Check that a Gradio app that has been deployed to a cluster through
      GradioIngress scales as needed, i.e. separate client requests are served by
      different replicas.
      """
  
      def f(*args):
          return os.getpid()
  
      app = GradioServer.options(num_replicas=2).bind(
          lambda: gr.Interface(fn=f, inputs="text", outputs="text")
      )
      serve.run(app)
  
      def two_pids_returned():
          @ray.remote
          def get_pid_from_request():
              r = requests.post(
                  "http://127.0.0.1:8000/api/predict/",
                  json={"data": ["input"]},
              )
              r.raise_for_status()
              return r.json()["data"][0]
  
          return (
              len(
                  set(
                      ray.get(
                          [
                              get_pid_from_request.remote()
                              for _ in range(10)
                          ]
                      )
                  )
              )
              == 2
          )
  
      # Verify that the requests are handled by two separate replicas.
      wait_for_condition(two_pids_returned)
  
file_path: ray/python/ray/serve/tests/test_gradio.py
imports: import os
  import sys
  import gradio
  import pytest
  import requests
  import ray
  from ray import serve
  from ray._private.test_utils import wait_for_condition
  from ray.serve.gradio_integrations import GradioIngress, GradioServer
label_desc: Use image node_id 3 for calling a global function with example usage: test_gradio_ingress_scaling(serve_start_shutdown) and returns: os, unknown, r