code: def test_sampler(
      shuffle: bool, skip: int, rank_size: Tuple[int, int]
  ) -> None:
      epoch_len = 100
      rank, size = rank_size
      seed = 777
  
      # Build a list of globally expected indices; just a stream of indices, shuffled every epoch.
      rng = np.random.RandomState(seed)
      all_indices = []
      one_epoch_indices = list(range(epoch_len))
      for _ in range(15):
          if shuffle:
              rng.shuffle(one_epoch_indices)
          all_indices += one_epoch_indices
  
      # Expect the appropriate shard of the stream for ourselves.
      expect_shard = [
          all_indices[i] for i in range(rank, len(all_indices), size)
      ]
  
      # Respect the number of batches we have already trained for.
      expect_indices = expect_shard[skip:]
  
      sampler = keras._Sampler(
          epoch_len, rank, size, shuffle, seed, skip
      )
  
      got_indices = list(sampler.yield_epoch())
      got_indices += list(sampler.yield_epoch())
      got_indices += list(sampler.yield_epoch())
  
      # Ensure we got an appropriate length of indices.
      shard_len = epoch_len // size
      exp_len = 3 * shard_len - (skip % epoch_len) % shard_len
      got_len = len(got_indices)
      assert abs(exp_len - got_len) <= 3
  
      assert got_indices == expect_indices[: len(got_indices)]
  
imports: from typing import Tuple
  import numpy
  import pytest
  from tensorflow.keras.utils import Sequence
  import determined
  from determined import keras
  from determined.common import check
  from tests.experiment import tf_utils
label_desc: Use image node_id 9 for calling a global function with example usage: test_sampler(shuffle, skip, rank_size) without return types