class_docstr: Tests for distributed save/load with the new load algorithm.
class_docstr_tok: ["Tests","for","distributed","save\/load","with","the","new","load","algorithm","."]
code: def test_distributed_load(
      self,
      num_workers: int,
      num_elements: int,
      repeated_load: int,
      sharding_policy: data_service_ops.ShardingPolicy,
  ):
      cluster = data_service_test_base.TestCluster(
          num_workers=num_workers
      )
      snapshot_dir = data_service_test_base.TempDir()
      dataset = dataset_ops.Dataset.range(num_elements)
      self.evaluate(
          distributed_save_op.distributed_save(
              dataset,
              snapshot_dir.full_path,
              cluster.dispatcher_address(),
          )
      )
  
      dataset = load_op._load_with_retry(snapshot_dir.full_path)
      if repeated_load > 1:
          dataset = dataset.repeat(repeated_load)
      dataset = dataset.apply(
          data_service_ops.distribute(
              sharding_policy, cluster.dispatcher_address()
          )
      )
      expected = list(range(num_elements)) * repeated_load
      if sharding_policy == data_service_ops.ShardingPolicy.OFF:
          expected *= num_workers
      self.assertDatasetProduces(
          dataset, expected, assert_items_equal=True
      )
  
imports: import multiprocessing
  import os
  import threading
  import time
  from typing import Callable, Optional
  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.experimental.ops import distributed_save_op
  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 load_op
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import errors
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import cond
  from tensorflow.python.ops import math_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 5 for calling the DistributedSaveLoadTest obj's underlying member method code with example usage: obj.test_distributed_load(num_workers, num_elements, repeated_load, sharding_policy) without return types