code: def test_autodetect_parallelism(
      shutdown_only,
      avail_cpus,
      target_max_block_size,
      data_size,
      expected,
  ):
      class MockReader:
          def estimate_inmemory_data_size(self):
              return data_size
  
      result, _, _, _ = _autodetect_parallelism(
          parallelism=-1,
          target_max_block_size=target_max_block_size,
          ctx=DataContext.get_current(),
          datasource_or_legacy_reader=MockReader(),
          avail_cpus=avail_cpus,
      )
      assert result == expected, (result, expected)
  
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 1 for calling a global function with example usage: test_autodetect_parallelism(shutdown_only, avail_cpus, target_max_block_size, data_size, expected) and returns: data_size