code: def testSampleFromDatasets(self):
      cluster = data_service_test_base.TestCluster(num_workers=3)
      num_samples = 200
      weights = [0.6, 0.3, 0.1]
      classes = len(weights)
  
      # Create a dataset that samples each integer in `[0, num_datasets)`
      # with probability given by `weights[i]`.
      ds = dataset_ops.Dataset.sample_from_datasets(
          [
              dataset_ops.Dataset.from_tensors(i).repeat()
              for i in range(classes)
          ],
          weights,
      )
      ds = self._make_dynamic_sharding_dataset(ds, cluster)
      ds = ds.take(num_samples)
  
      freqs = np.zeros([classes])
      for v in self.getDatasetOutput(ds, requires_initialization=True):
          freqs[v] += 1
  
      self.assertGreater(freqs[0], freqs[1])
      self.assertGreater(freqs[1], freqs[2])
  
imports: import collections
  from absl.testing import parameterized
  import numpy
  from tensorflow.python.data.experimental.kernel_tests.service import test_base
  from tensorflow.python.data.experimental.ops import data_service_ops
  from tensorflow.python.data.kernel_tests import test_base
  from tensorflow.python.data.kernel_tests import tf_record_test_base
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.data.ops import readers
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import errors
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import random_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 21 for calling the DynamicShardingTest obj's underlying member method code with example usage: obj.testSampleFromDatasets() without return types