code: def test_generator_errors(
      ray_start_regular, use_actors, store_in_plasma, num_returns_type
  ):
      remote_generator_fn = None
      if use_actors:
  
          @ray.remote
          class Generator:
              def __init__(self):
                  pass
  
              def generator(self, num_returns, store_in_plasma):
                  for i in range(num_returns - 2):
                      if store_in_plasma:
                          yield np.ones(1_000_000, dtype=np.int8) * i
                      else:
                          yield [i]
                  raise Exception("error")
  
          g = Generator.remote()
          remote_generator_fn = g.generator
      else:
  
          @ray.remote(max_retries=0)
          def generator(num_returns, store_in_plasma):
              for i in range(num_returns - 2):
                  if store_in_plasma:
                      yield np.ones(1_000_000, dtype=np.int8) * i
                  else:
                      yield [i]
              raise Exception("error")
  
          remote_generator_fn = generator
  
      ref1, ref2, ref3 = remote_generator_fn.options(
          num_returns=3
      ).remote(3, store_in_plasma)
      ray.get(ref1)
      with pytest.raises(ray.exceptions.RayTaskError):
          ray.get(ref2)
      with pytest.raises(ray.exceptions.RayTaskError):
          ray.get(ref3)
  
      dynamic_ref = remote_generator_fn.options(
          num_returns=num_returns_type
      ).remote(3, store_in_plasma)
      ref1, ref2 = ray.get(dynamic_ref)
      ray.get(ref1)
      with pytest.raises(ray.exceptions.RayTaskError):
          ray.get(ref2)
  
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 4 for calling a global function with example usage: test_generator_errors(ray_start_regular, use_actors, store_in_plasma, num_returns_type) without return types