code: def test_generator_oom(ray_start_regular):
      num_returns = 100
  
      @ray.remote(max_retries=0)
      def large_values(num_returns):
          return [
              np.random.randint(
                  np.iinfo(np.int8).max,
                  size=(100_000_000, 1),
                  dtype=np.int8,
              )
              for _ in range(num_returns)
          ]
  
      @ray.remote(max_retries=0)
      def large_values_generator(num_returns):
          for _ in range(num_returns):
              yield np.random.randint(
                  np.iinfo(np.int8).max,
                  size=(100_000_000, 1),
                  dtype=np.int8,
              )
  
      try:
          # Worker may OOM using normal returns.
          ray.get(
              large_values.options(num_returns=num_returns).remote(
                  num_returns
              )[0]
          )
      except ray.exceptions.WorkerCrashedError:
          pass
  
      # Using a generator will allow the worker to finish.
      ray.get(
          large_values_generator.options(
              num_returns=num_returns
          ).remote(num_returns)[0]
      )
  
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 2 for calling a global function with example usage: test_generator_oom(ray_start_regular) and returns: unknown