code: def test_group_by_key(self):
      def gen_data(N, step):
          for i in range(1, N + 1, step):
              for j in range(i):
                  yield (i, [j])
  
      def gen_gs(N, step=1):
          return shuffle.GroupByKey(gen_data(N, step))
  
      self.assertEqual(1, len(list(gen_gs(1))))
      self.assertEqual(2, len(list(gen_gs(2))))
      self.assertEqual(100, len(list(gen_gs(100))))
      self.assertEqual(list(range(1, 101)), [k for k, _ in gen_gs(100)])
      self.assertTrue(
          all(list(range(k)) == list(vs) for k, vs in gen_gs(100))
      )
  
      for k, vs in gen_gs(50002, 10000):
          self.assertEqual(k, len(vs))
          self.assertEqual(list(range(k)), list(vs))
  
      ser = CPickleSerializer()
      lst = ser.loads(ser.dumps(list(gen_gs(50002, 30000))))
      for k, vs in lst:
          self.assertEqual(k, len(vs))
          self.assertEqual(list(range(k)), list(vs))
  
imports: import random
  import unittest
  import tempfile
  import os
  from py4j.protocol import Py4JJavaError
  from pyspark import shuffle, CPickleSerializer, SparkConf, SparkContext
  from pyspark.shuffle import Aggregator, ExternalMerger, ExternalSorter, SimpleAggregator, Merger, ExternalGroupBy
label_desc: Use image node_id 8 for calling the MergerTests obj's underlying member method code with example usage: obj.test_group_by_key() and returns: shuffle