class_docstr: Group by the items by key. If any partition of them can not been
  hold in memory, it will do sort based group by.
  
  This class works as follows:
  
  - It repeatedly group the items by key and save them in one dict in
    memory.
  
  - When the used memory goes above memory limit, it will split
    the combined data into partitions by hash code, dump them
    into disk, one file per partition. If the number of keys
    in one partitions is smaller than 1000, it will sort them
    by key before dumping into disk.
  
  - Then it goes through the rest of the iterator, group items
    by key into different dict by hash. Until the used memory goes over
    memory limit, it dump all the dicts into disks, one file per
    dict. Repeat this again until combine all the items. It
    also will try to sort the items by key in each partition
    before dumping into disks.
  
  - It will yield the grouped items partitions by partitions.
    If the data in one partitions can be hold in memory, then it
    will load and combine them in memory and yield.
  
  - If the dataset in one partition cannot be hold in memory,
    it will sort them first. If all the files are already sorted,
    it merge them by heap.merge(), so it will do external sort
    for all the files.
  
  - After sorting, `GroupByKey` class will put all the continuous
    items with the same key as a group, yield the values as
    an iterator.
class_docstr_tok: ["Group","by","the","items","by","key",".","If","any","partition","of","them","can","not","been","hold","in","memory",",","it","will","do","sort","based","group","by",".","This","class","works","as","follows",":","-","It","repeatedly","group","the","items","by","key","and","save","them","in","one","dict","in","memory",".","-","When","the","used","memory","goes","above","memory","limit",",","it","will","split","the","combined","data","into","partitions","by","hash","code",",","dump","them","into","disk",",","one","file","per","partition",".","If","the","number","of","keys","in","one","partitions","is","smaller","than","1000",",","it","will","sort","them","by","key","before","dumping","into","disk",".","-","Then","it","goes","through","the","rest","of","the","iterator",",","group","items","by","key","into","different","dict","by","hash",".","Until","the","used","memory","goes","over","memory","limit",",","it","dump","all","the","dicts","into","disks",",","one","file","per","dict",".","Repeat","this","again","until","combine","all","the","items",".","It","also","will","try","to","sort","the","items","by","key","in","each","partition","before","dumping","into","disks",".","-","It","will","yield","the","grouped","items","partitions","by","partitions",".","If","the","data","in","one","partitions","can","be","hold","in","memory",",","then","it","will","load","and","combine","them","in","memory","and","yield",".","-","If","the","dataset","in","one","partition","can","not","be","hold","in","memory",",","it","will","sort","them","first",".","If","all","the","files","are","already","sorted",",","it","merge","them","by","heap.merge","(",")",",","so","it","will","do","external","sort","for","all","the","files",".","-","After","sorting",",","`","GroupByKey","`","class","will","put","all","the","continuous","items","with","the","same","key","as","a","group",",","yield","the","values","as","an","iterator","."]
code: def flattened_serializer(self):
      assert isinstance(self.serializer, BatchedSerializer)
      ser = self.serializer
      return FlattenedValuesSerializer(ser, 20)
  
imports: import os
  import platform
  import shutil
  import warnings
  import gc
  import itertools
  import operator
  import random
  import sys
  import heapq
  from pyspark.serializers import BatchedSerializer, CPickleSerializer, FlattenedValuesSerializer, CompressedSerializer, AutoBatchedSerializer
  from pyspark.util import fail_on_stopiteration
label_desc: Use image node_id 1 for calling the ExternalGroupBy obj's underlying member method code with example usage: obj.flattened_serializer() and returns: FlattenedValuesSerializer