code: def testBasic(self):
      components = (
          np.array([1, 2, 3, 4]),
          np.array([5, 6, 7, 8]),
          np.array([9.0, 10.0, 11.0, 12.0]),
      )
  
      def dataset_fn(count=5, buffer_size=None, seed=0):
          repeat_dataset = dataset_ops.Dataset.from_tensor_slices(
              components
          ).repeat(count)
          if buffer_size:
              shuffle_dataset = repeat_dataset.shuffle(
                  buffer_size, seed
              )
  
              self.assertEqual(
                  tuple([c.shape[1:] for c in components]),
                  dataset_ops.get_legacy_output_shapes(shuffle_dataset),
              )
              return shuffle_dataset
          else:
              return repeat_dataset
  
      # First run without shuffling to collect the "ground truth".
      get_next = self.getNext(dataset_fn())
      unshuffled_elements = []
      for _ in range(20):
          unshuffled_elements.append(self.evaluate(get_next()))
      with self.assertRaises(errors.OutOfRangeError):
          self.evaluate(get_next())
  
      # Assert that the shuffled dataset has the same elements as the
      # "ground truth".
      get_next = self.getNext(dataset_fn(buffer_size=100, seed=37))
      shuffled_elements = []
      for _ in range(20):
          shuffled_elements.append(self.evaluate(get_next()))
      with self.assertRaises(errors.OutOfRangeError):
          self.evaluate(get_next())
      with self.assertRaises(errors.OutOfRangeError):
          self.evaluate(get_next())
      self.assertAllEqual(
          sorted(unshuffled_elements), sorted(shuffled_elements)
      )
  
      # Assert that shuffling twice with the same seeds gives the same sequence.
      get_next = self.getNext(dataset_fn(buffer_size=100, seed=37))
      reshuffled_elements_same_seed = []
      for _ in range(20):
          reshuffled_elements_same_seed.append(
              self.evaluate(get_next())
          )
      with self.assertRaises(errors.OutOfRangeError):
          self.evaluate(get_next())
      self.assertEqual(shuffled_elements, reshuffled_elements_same_seed)
  
      # Assert that shuffling twice with a different seed gives a different
      # permutation of the same elements.
      get_next = self.getNext(dataset_fn(buffer_size=100, seed=137))
      reshuffled_elements_different_seed = []
      for _ in range(20):
          reshuffled_elements_different_seed.append(
              self.evaluate(get_next())
          )
      with self.assertRaises(errors.OutOfRangeError):
          self.evaluate(get_next())
      self.assertNotEqual(
          shuffled_elements, reshuffled_elements_different_seed
      )
      self.assertAllEqual(
          sorted(shuffled_elements),
          sorted(reshuffled_elements_different_seed),
      )
  
      # Assert that the shuffled dataset has the same elements as the
      # "ground truth" when the buffer size is smaller than the input
      # dataset.
      get_next = self.getNext(dataset_fn(buffer_size=2, seed=37))
      reshuffled_elements_small_buffer = []
      for _ in range(20):
          reshuffled_elements_small_buffer.append(
              self.evaluate(get_next())
          )
      with self.assertRaises(errors.OutOfRangeError):
          self.evaluate(get_next())
      self.assertAllEqual(
          sorted(unshuffled_elements),
          sorted(reshuffled_elements_small_buffer),
      )
  
      # Test the case of shuffling an empty dataset.
      get_next = self.getNext(
          dataset_fn(count=0, buffer_size=100, seed=37)
      )
  
      with self.assertRaises(errors.OutOfRangeError):
          self.evaluate(get_next())
  
imports: import collections
  import functools
  import sys
  from absl.testing import parameterized
  import numpy
  from tensorflow.python import pywrap_sanitizers
  from tensorflow.python.checkpoint import checkpoint
  from tensorflow.python.checkpoint import checkpoint_management
  from tensorflow.python.data.experimental.ops import iterator_ops
  from tensorflow.python.data.experimental.ops import random_access
  from tensorflow.python.data.kernel_tests import checkpoint_test_base
  from tensorflow.python.data.kernel_tests import test_base
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.data.ops import options
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import random_seed
  from tensorflow.python.framework import tensor_spec
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import check_ops
  from tensorflow.python.ops import stateless_random_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
  from tensorflow.python.training import saver
label_desc: Use image node_id 1 for calling the ShuffleTest obj's underlying member method code with example usage: obj.testBasic() and returns: shuffle_dataset, repeat_dataset