code: def testEdgeCasesSampleFromInitialDataset(self, only_initial_dist):
      init_dist = [0.5, 0.5]
      target_dist = [0.5, 0.5] if only_initial_dist else [0.0, 1.0]
      num_classes = len(init_dist)
      # We don't need many samples to test that this works.
      num_samples = 100
      data_np = np.random.choice(num_classes, num_samples, p=init_dist)
  
      dataset = dataset_ops.Dataset.from_tensor_slices(data_np)
  
      # Reshape distribution.
      dataset = dataset.rejection_resample(
          class_func=lambda x: x,
          target_dist=target_dist,
          initial_dist=init_dist,
      )
  
      get_next = self.getNext(dataset)
  
      returned = []
      with self.assertRaises(errors.OutOfRangeError):
          while True:
              returned.append(self.evaluate(get_next()))
  
file_path: tensorflow-upstream/tensorflow/python/data/kernel_tests/rejection_resample_test.py
imports: from absl.testing import parameterized
  import numpy
  from tensorflow.python.data.kernel_tests import test_base
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import random_ops
  from tensorflow.python.ops import string_ops
  from tensorflow.python.platform import test
  from tensorflow.python.util import compat
label_desc: Use image node_id 2 for calling the RejectionResampleTest obj's underlying member method code with example usage: obj.testEdgeCasesSampleFromInitialDataset(only_initial_dist) without return types