code: def test_dynamic_generator_reconstruction_fails(
      ray_start_cluster, num_returns_type
  ):
      config = {
          "health_check_failure_threshold": 10,
          "health_check_period_ms": 100,
          "health_check_initial_delay_ms": 0,
          "max_direct_call_object_size": 100,
          "task_retry_delay_ms": 100,
          "object_timeout_milliseconds": 200,
          "fetch_warn_timeout_milliseconds": 1000,
      }
      cluster = ray_start_cluster
      cluster.add_node(
          num_cpus=1,
          _system_config=config,
          enable_object_reconstruction=True,
          resources={"head": 1},
      )
      ray.init(address=cluster.address)
      # Node to place the initial object.
      node_to_kill = cluster.add_node(
          num_cpus=1, object_store_memory=10**8
      )
      cluster.wait_for_nodes()
  
      @ray.remote(num_cpus=1, resources={"head": 1})
      class FailureSignal:
          def __init__(self):
              return
  
          def ping(self):
              return
  
      @ray.remote(num_returns=num_returns_type)
      def dynamic_generator(failure_signal):
          num_returns = 10
          for i in range(num_returns):
              yield np.ones(1_000_000, dtype=np.int8) * i
              if i == num_returns // 2:
                  # If this is the re-execution, fail the worker after partial yield.
                  try:
                      ray.get(failure_signal.ping.remote())
                  except ray.exceptions.RayActorError:
                      sys.exit(-1)
  
      @ray.remote
      def fetch(*refs):
          pass
  
      failure_signal = FailureSignal.remote()
      gen = ray.get(dynamic_generator.remote(failure_signal))
      refs = list(gen)
      ray.get(fetch.remote(*refs))
      cluster.remove_node(node_to_kill, allow_graceful=False)
      done = fetch.remote(*refs)
      ray.kill(failure_signal)
      # Make sure we can get the error.
      with pytest.raises(ray.exceptions.WorkerCrashedError):
          for ref in refs:
              ray.get(ref)
  
      # Make sure other tasks can also get the error.
      with pytest.raises(ray.exceptions.RayTaskError):
          ray.get(done)
  
      del ref, gen, refs, done, failure_signal
      gc.collect()
      assert_no_leak()
  
imports: import pytest
  import numpy
  import sys
  import time
  import gc
  from unittest.mock import Mock
  import ray
  from ray.util.client.ray_client_helpers import ray_start_client_server_for_address
  from ray._private.client_mode_hook import enable_client_mode
  from ray.tests.conftest import call_ray_start_context
label_desc: Use image node_id 10 for calling a global function with example usage: test_dynamic_generator_reconstruction_fails(ray_start_cluster, num_returns_type) without return types