code: def test_generators(serve_instance):
      """Test generators inside and outside a deployment."""
  
      @serve.deployment
      def downstream():
          for i in range(10):
              yield i
  
      @serve.deployment
      class Deployment:
          def __init__(self, handle: RayServeHandle):
              self._handle = handle.options(
                  use_new_handle_api=True, stream=True
              )
  
          async def __call__(self):
              gen = self._handle.remote()
              assert isinstance(gen, DeploymentResponseGenerator)
              async for i in gen:
                  yield i
  
      handle = serve.run(Deployment.bind(downstream.bind())).options(
          use_new_handle_api=True
      )
  
      gen = handle.options(stream=True).remote()
      assert isinstance(gen, DeploymentResponseGenerator)
      assert list(gen) == list(range(10))
  
file_path: ray/python/ray/serve/tests/test_new_handle_api.py
imports: import sys
  from typing import Any
  import pytest
  import ray
  from ray import serve
  from ray._private.test_utils import SignalActor
  from ray.serve.handle import DeploymentHandle, DeploymentResponse, DeploymentResponseGenerator, RayServeHandle, RayServeSyncHandle
label_desc: Use image node_id 7 for calling a global function with example usage: test_generators(serve_instance) without return types