code: def test_auto_parallelism_basic(shutdown_only):
      ray.init(num_cpus=8)
      context = DataContext.get_current()
      context.min_parallelism = 1
      # Datasource bound.
      ds = ray.data.range_tensor(5, shape=(100,), parallelism=-1)
      assert ds.num_blocks() == 5, ds
      # CPU bound. TODO(ekl) we should fix range datasource to respect parallelism more
      # properly, currently it can go a little over.
      ds = ray.data.range_tensor(10000, shape=(100,), parallelism=-1)
      assert ds.num_blocks() == 16, ds
      # Block size bound.
      ds = ray.data.range_tensor(
          100000000, shape=(100,), parallelism=-1
      )
      assert ds.num_blocks() >= 590, ds
      assert ds.num_blocks() <= 600, ds
  
file_path: ray/python/ray/data/tests/test_auto_parallelism.py
imports: from dataclasses import astuple, dataclass
  import pytest
  import ray
  from ray.data._internal.util import _autodetect_parallelism
  from ray.data.context import DataContext
  from ray.tests.conftest import *
  from ray.util.scheduling_strategies import PlacementGroupSchedulingStrategy
label_desc: Use image node_id 2 for calling a global function with example usage: test_auto_parallelism_basic(shutdown_only) without return types