code: def assign_sub_sets(samples):
      sample_size = get_sample_size(len(samples))
      speakers = group(samples, lambda sample: sample.speaker).values()
      speakers = list(sorted(speakers, key=len))
      sample_sets = [[], []]
      while (
          any(map(lambda s: len(s) < sample_size, sample_sets))
          and len(speakers) > 0
      ):
          for sample_set in sample_sets:
              if len(sample_set) < sample_size and len(speakers) > 0:
                  sample_set.extend(speakers.pop(0))
      train_set = sum(speakers, [])
      if len(train_set) == 0:
          print(
              "WARNING: Unable to build dev and test sets without speaker bias as there is no speaker meta data"
          )
          random.seed(42)  # same source data == same output
          random.shuffle(samples)
          for index, sample in enumerate(samples):
              if index < sample_size:
                  sample.sub_set = "dev"
              elif index < 2 * sample_size:
                  sample.sub_set = "test"
              else:
                  sample.sub_set = "train"
      else:
          for sub_set, sub_set_samples in [
              ("train", train_set),
              ("dev", sample_sets[0]),
              ("test", sample_sets[1]),
          ]:
              for sample in sub_set_samples:
                  sample.sub_set = sub_set
      for sub_set, sub_set_samples in group(
          samples, lambda s: s.sub_set
      ).items():
          t = sum(map(lambda s: s.end - s.start, sub_set_samples)) / (
              1000 * 60 * 60
          )
          print(
              'Sub-set "{}" with {} samples (duration: {:.2f} h)'.format(
                  sub_set, len(sub_set_samples), t
              )
          )
  
imports: import argparse
  import csv
  import os
  import random
  import re
  import shutil
  import sys
  import tarfile
  import unicodedata
  import wave
  import xml.etree.ElementTree
  from collections import Counter
  from glob import glob
  from multiprocessing.pool import ThreadPool
  import progressbar
  import sox
  from deepspeech_training.util.downloader import SIMPLE_BAR, maybe_download
  from deepspeech_training.util.importers import validate_label_eng
  from ds_ctcdecoder import Alphabet
label_desc: Use image node_id 14 for calling a global function with example usage: assign_sub_sets(samples) without return types