code: def test_scheduling_progress_when_output_blocked(
      ray_start_10_cpus_shared, restore_data_context
  ):
      # Processing stages should fully finish even if output is completely stalled.
  
      @ray.remote
      class Counter:
          def __init__(self):
              self.i = 0
  
          def inc(self):
              self.i += 1
  
          def get(self):
              return self.i
  
      counter = Counter.remote()
  
      def func(x):
          ray.get(counter.inc.remote())
          return x
  
      DataContext.get_current().use_streaming_executor = True
      DataContext.get_current().execution_options.preserve_order = True
  
      # Only take the first item from the iterator.
      it = iter(
          ray.data.range(100, parallelism=100)
          .map_batches(func, batch_size=None)
          .iter_batches(batch_size=None)
      )
      next(it)
      # The pipeline should fully execute even when the output iterator is blocked.
      wait_for_condition(lambda: ray.get(counter.get.remote()) == 100)
      # Check we can take the rest.
      assert [b["id"] for b in it] == [[x] for x in range(1, 100)]
  
imports: import itertools
  import random
  import threading
  import time
  from typing import Any, List
  import pandas
  import pytest
  import ray
  from ray import cloudpickle
  from ray._private.test_utils import wait_for_condition
  from ray.data._internal.execution.interfaces import ExecutionOptions, ExecutionResources, RefBundle
  from ray.data._internal.execution.operators.base_physical_operator import AllToAllOperator
  from ray.data._internal.execution.operators.input_data_buffer import InputDataBuffer
  from ray.data._internal.execution.operators.map_operator import MapOperator
  from ray.data._internal.execution.operators.map_transformer import create_map_transformer_from_block_fn
  from ray.data._internal.execution.operators.output_splitter import OutputSplitter
  from ray.data._internal.execution.streaming_executor import StreamingExecutor
  from ray.data._internal.execution.util import make_ref_bundles
  from ray.data.context import DataContext
  from ray.data.tests.conftest import *
  from ray.data.tests.util import extract_values
label_desc: Use image node_id 11 for calling a global function with example usage: test_scheduling_progress_when_output_blocked(ray_start_10_cpus_shared, restore_data_context) and returns: x, self