code: def test_spark_examples_iterable_shuffle():
      spark = (
          pyspark.sql.SparkSession.builder.master("local[*]")
          .appName("pyspark")
          .getOrCreate()
      )
      df = spark.range(30).repartition(3)
      # Mock the generator so that shuffle reverses the partition indices.
      with patch("numpy.random.Generator") as generator_mock:
          generator_mock.shuffle.side_effect = lambda x: x.reverse()
          expected_row_ids_and_row_dicts = (
              _get_expected_row_ids_and_row_dicts_for_partition_order(
                  df, [2, 1, 0]
              )
          )
  
          shuffled_it = SparkExamplesIterable(df).shuffle_data_sources(
              generator_mock
          )
          assert shuffled_it.n_shards == 3
          for i, (row_id, row_dict) in enumerate(shuffled_it):
              (
                  expected_row_id,
                  expected_row_dict,
              ) = expected_row_ids_and_row_dicts[i]
              assert row_id == expected_row_id
              assert row_dict == expected_row_dict
  
file_path: datasets/tests/packaged_modules/test_spark.py
imports: from unittest.mock import patch
  import pyspark
  from datasets.packaged_modules.spark.spark import Spark, SparkExamplesIterable, _generate_iterable_examples
  from ..utils import require_dill_gt_0_3_2, require_not_windows
label_desc: Use image node_id 5 for calling a global function with example usage: test_spark_examples_iterable_shuffle() without return types