code: def test_sharded_iterator(self):
      # test correctness
      x = list(range(10))
      itr = iterators.ShardedIterator(x, num_shards=1, shard_id=0)
      self.assertEqual(list(itr), x)
      itr = iterators.ShardedIterator(x, num_shards=2, shard_id=0)
      self.assertEqual(list(itr), [0, 2, 4, 6, 8])
      itr = iterators.ShardedIterator(x, num_shards=2, shard_id=1)
      self.assertEqual(list(itr), [1, 3, 5, 7, 9])
      itr = iterators.ShardedIterator(x, num_shards=3, shard_id=0)
      self.assertEqual(list(itr), [0, 3, 6, 9])
      itr = iterators.ShardedIterator(x, num_shards=3, shard_id=1)
      self.assertEqual(list(itr), [1, 4, 7, None])
      itr = iterators.ShardedIterator(x, num_shards=3, shard_id=2)
      self.assertEqual(list(itr), [2, 5, 8, None])
  
      # test CountingIterator functionality
      x = list(range(30))
      ref = list(iterators.ShardedIterator(x, num_shards=3, shard_id=0))
      itr = iterators.ShardedIterator(x, num_shards=3, shard_id=0)
      self.test_counting_iterator_index(ref, itr)
  
file_path: fairseq/tests/test_iterators.py
imports: import unittest
  from fairseq.data import iterators, ListDataset
label_desc: Use image node_id 5 for calling the TestIterators obj's underlying member method code with example usage: obj.test_sharded_iterator() without return types