def generate_ngram_examples(model: NGramGenerator,
                            min_length: int,
                            max_length: int,
                            num_buckets: int,
                            min_score: float,
                            num_iterations: int,
                            random_seed: int = 1) -> List[ScoredNGram]:
  """Generates a sorted list of scored new words based on the requirements.

  Args:
    model: Trained model to create and score words.
    min_length: The minimum length of which to create new words.
    max_length: The maximum length of which to create new words.
    num_buckets: The number of buckets from which to stratify the scoring.
    min_score: The minimum allowed score. Note that each bucket will then be an
      equal range between 0 and this value.
    num_iterations: The number of initial examples to be created. Note that many
      of the examples will be filtered, depending on the other arguments and
      others will be subsampled via the buckets. In general, specify this to be
      larger than the number of examples needed.
    random_seed: Random seed of the process to multiply by.

  Returns:
    A list of scored words following the above requirements.
  """
  score_buckets = collections.defaultdict(list)
  word_set = set()
  for i in range(num_iterations):
    scored_ngram = model.make_scored_ngram(max_length, seed=i * random_seed)
    if scored_ngram.word in word_set:
      continue
    word_set.add(scored_ngram.word)
    if model.validate_scored_ngram(scored_ngram, min_score, min_length):
      bucket = _get_bucket(scored_ngram, min_score, num_buckets)
      score_buckets[bucket].append(scored_ngram)

  final = []
  max_examples_per_bucket = num_iterations // num_buckets
  for ngram_score_list in score_buckets.values():
    final.extend(ngram_score_list[:max_examples_per_bucket])
  return sorted(final, key=lambda sn: -sn.score)
Generates a sorted list of scored new words based on the requirements.

  Args:
    model: Trained model to create and score words.
    min_length: The minimum length of which to create new words.
    max_length: The maximum length of which to create new words.
    num_buckets: The number of buckets from which to stratify the scoring.
    min_score: The minimum allowed score. Note that each bucket will then be an
      equal range between 0 and this value.
    num_iterations: The number of initial examples to be created. Note that many
      of the examples will be filtered, depending on the other arguments and
      others will be subsampled via the buckets. In general, specify this to be
      larger than the number of examples needed.
    random_seed: Random seed of the process to multiply by.

  Returns:
    A list of scored words following the above requirements.
  
language/wino_dict/create_new_words.py