code: def check_shard_sampler(
      self, dataset, batch_size, drop_last, num_processes=2
  ):
      shards = [
          ShardSampler(
              dataset,
              batch_size=batch_size,
              drop_last=drop_last,
              num_processes=num_processes,
              process_index=i,
          )
          for i in range(num_processes)
      ]
      shard_lists = [list(shard) for shard in shards]
  
      for shard in shard_lists:
          # All shards have a number of samples that is a round multiple of batch size
          self.assertTrue(len(shard) % batch_size == 0)
          # All shards have the same number of samples
          self.assertEqual(len(shard), len(shard_lists[0]))
  
      observed = []
      for idx in range(0, len(shard_lists[0]), batch_size):
          for shard in shard_lists:
              observed += shard[idx : idx + batch_size]
  
      # If drop_last is False we loop through samples at the beginning to have a size that is a round multiple of
      # batch_size
      reference = copy.copy(dataset)
      if not drop_last:
          while len(reference) < len(observed):
              reference += reference
      self.assertListEqual(observed, reference[: len(observed)])
  
imports: import copy
  import unittest
  import numpy
  from transformers.data.data_collator import default_data_collator
  from transformers.testing_utils import require_accelerate, require_torch
  from transformers.trainer_utils import RemoveColumnsCollator, find_executable_batch_size
  from transformers.utils import is_torch_available
label_desc: Use image node_id 14 for calling the TrainerUtilsTest obj's underlying member method code with example usage: obj.check_shard_sampler(dataset, batch_size, drop_last, num_processes) without return types