code: def __init__(self, num_workers: int, expect_random: bool, **kwargs):
      def train_loop_per_worker():
          data_shard = train.get_dataset_shard("train")
          assert isinstance(data_shard, DataIterator), data_shard
          epoch1 = list(data_shard.iter_rows())
          epoch2 = list(data_shard.iter_rows())
          print("Epochs", epoch1, "\n", epoch2)
          if expect_random:
              assert epoch1 != epoch2
          else:
              assert epoch1 == epoch2
  
      kwargs.pop("scaling_config", None)
      super().__init__(
          train_loop_per_worker=train_loop_per_worker,
          scaling_config=ScalingConfig(num_workers=num_workers),
          **kwargs,
      )
  
imports: from typing import Optional
  import random
  import pytest
  from unittest.mock import MagicMock
  import ray
  from ray import train
  from ray.train import DataConfig, ScalingConfig
  from ray.data import DataIterator
  from ray.train.data_parallel_trainer import DataParallelTrainer
  from ray.data._internal.execution.interfaces.execution_options import ExecutionOptions
  from ray.tests.conftest import *
label_desc: Use image node_id 1 to create a new TestRandom object from inherited base classes: DataParallelTrainer with example: obj = TestRandom(num_workers, expect_random)