class_docstr: Tests reading from local workers if `target_workers` is `local`.
class_docstr_tok: ["Tests","reading","from","local","workers","if","`","target_workers","`","is","`","local","`","."]
code: def testMultipleConsumers(self):
      num_local_workers, num_remote_workers = 1, 3
      cluster = multi_process_cluster.MultiProcessCluster(
          num_local_workers=num_local_workers,
          num_remote_workers=num_remote_workers,
      )
      # Because the elements in datasets are prefetched one per
      # CPU core, a static number here may be excessively large
      # for small numbers of CPU cores, or too small for high
      # CPU core count machines, or probably both.
      # In this case the below formula should satisfy both needs.
      num_elements = 50 + (multiprocessing.cpu_count() * 2)
      num_consumers = 8
      iterators = []
      for _ in range(num_consumers):
          dataset = self.make_distributed_range_dataset(
              num_elements, cluster, job_name="shared_job"
          )
          iterators.append(self.getNext(dataset))
  
      results = []
      for _ in range(10):
          for it in iterators:
              results.append(self.evaluate(it()))
      for it in iterators:
          results.extend(self.getIteratorOutput(it))
  
      self.assertCountEqual(
          results,
          (num_local_workers + num_remote_workers)
          * list(range(num_elements)),
      )
  
imports: import multiprocessing
  from absl.testing import parameterized
  from tensorflow.python.data.experimental.kernel_tests.service import multi_process_cluster
  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.ops import dataset_ops
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import errors
label_desc: Use image node_id 7 for calling the LocalWorkersTest obj's underlying member method code with example usage: obj.testMultipleConsumers() without return types