code: def testSampleFromDatasets(self, weights_type):
      random_seed.set_random_seed(1619)
      num_samples = 5000
      rand_probs = self._normalize(np.random.random_sample((5,)))
  
      # Use chi-squared test to assert that the observed distribution matches the
      # expected distribution. Based on the implementation in
      # "third_party/tensorflow/python/kernel_tests/multinomial_op_test.py".
      for probs in [[0.85, 0.05, 0.1], rand_probs, [1.0]]:
          weights = _get_weights_of_type(
              np.asarray(probs), weights_type
          )
          classes = len(probs)
  
          # Create a dataset that samples each integer in `[0, num_datasets)`
          # with probability given by `weights[i]`.
          dataset = dataset_ops.Dataset.sample_from_datasets(
              [
                  dataset_ops.Dataset.from_tensors(i).repeat()
                  for i in range(classes)
              ],
              weights,
          )
          dataset = dataset.take(num_samples)
  
          next_element = self.getNext(
              dataset, requires_initialization=True
          )
          freqs = np.zeros([classes])
          for _ in range(num_samples):
              freqs[self.evaluate(next_element())] += 1
          with self.assertRaises(errors.OutOfRangeError):
              self.evaluate(next_element())
  
          self.assertLess(self._chi2(probs, freqs / num_samples), 1e-2)
  
imports: from absl.testing import parameterized
  import numpy
  from tensorflow.python.compat import compat
  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 errors
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import random_seed
  from tensorflow.python.platform import test
label_desc: Use image node_id 3 for calling the SampleFromDatasetsTest obj's underlying member method code with example usage: obj.testSampleFromDatasets(weights_type) without return types