class_docstr: ABC for Language Models.
  
  Cannot be directly instantiated itself.
docstr: Generate words from the model.
  
  :param int num_words: How many words to generate. By default 1.
  :param text_seed: Generation can be conditioned on preceding context.
  :param random_seed: A random seed or an instance of `random.Random`. If provided,
      makes the random sampling part of generation reproducible.
  :return: One (str) word or a list of words generated from model.
  
  Examples:
  
  >>> from nltk.lm import MLE
  >>> lm = MLE(2)
  >>> lm.fit([[("a", "b"), ("b", "c")]], vocabulary_text=['a', 'b', 'c'])
  >>> lm.fit([[("a",), ("b",), ("c",)]])
  >>> lm.generate(random_seed=3)
  'a'
  >>> lm.generate(text_seed=['a'])
  'b'
docstr_tok: ["Generate","words","from","the","model",".",":","param","int","num_words",":","How","many","words","to","generate",".","By","default","1.",":","param","text_seed",":","Generation","can","be","conditioned","on","preceding","context",".",":","param","random_seed",":","A","random","seed","or","an","instance","of","`","random.Random","`",".","If","provided",",","makes","the","random","sampling","part","of","generation","reproducible",".",":","return",":","One","(","str",")","word","or","a","list","of","words","generated","from","model",".","Examples",":",">",">",">","from","nltk.lm","import","MLE",">",">",">","lm","=","MLE","(","2",")",">",">",">","lm.fit","(","[","[","(","``","a","''",",","``","b","''",")",",","(","``","b","''",",","``","c","''",")","]","]",",","vocabulary_text=","[","'","a","'",",","'","b","'",",","'","c","'","]",")",">",">",">","lm.fit","(","[","[","(","``","a","''",",",")",",","(","``","b","''",",",")",",","(","``","c","''",",",")","]","]",")",">",">",">","lm.generate","(","random_seed=3",")","'","a'",">",">",">","lm.generate","(","text_seed=","[","'","a","'","]",")","'","b","'"]
code: def generate(self, num_words=1, text_seed=None, random_seed=None):
      """Generate words from the model.
  
      :param int num_words: How many words to generate. By default 1.
      :param text_seed: Generation can be conditioned on preceding context.
      :param random_seed: A random seed or an instance of `random.Random`. If provided,
          makes the random sampling part of generation reproducible.
      :return: One (str) word or a list of words generated from model.
  
      Examples:
  
      >>> from nltk.lm import MLE
      >>> lm = MLE(2)
      >>> lm.fit([[("a", "b"), ("b", "c")]], vocabulary_text=['a', 'b', 'c'])
      >>> lm.fit([[("a",), ("b",), ("c",)]])
      >>> lm.generate(random_seed=3)
      'a'
      >>> lm.generate(text_seed=['a'])
      'b'
  
      """
      text_seed = [] if text_seed is None else list(text_seed)
      random_generator = _random_generator(random_seed)
      # This is the base recursion case.
      if num_words == 1:
          context = (
              text_seed[-self.order + 1 :]
              if len(text_seed) >= self.order
              else text_seed
          )
          samples = self.context_counts(self.vocab.lookup(context))
          while context and not samples:
              context = context[1:] if len(context) > 1 else []
              samples = self.context_counts(self.vocab.lookup(context))
          # Sorting samples achieves two things:
          # - reproducible randomness when sampling
          # - turns Mapping into Sequence which `_weighted_choice` expects
          samples = sorted(samples)
          return _weighted_choice(
              samples,
              tuple(self.score(w, context) for w in samples),
              random_generator,
          )
      # We build up text one word at a time using the preceding context.
      generated = []
      for _ in range(num_words):
          generated.append(
              self.generate(
                  num_words=1,
                  text_seed=text_seed + generated,
                  random_seed=random_generator,
              )
          )
      return generated
  
imports: import random
  import warnings
  from abc import ABCMeta, abstractmethod
  from bisect import bisect
  from itertools import accumulate
  from nltk.lm.counter import NgramCounter
  from nltk.lm.util import log_base2
  from nltk.lm.vocabulary import Vocabulary
label_desc: Use image node_id 9 for calling the LanguageModel obj's underlying member method code with example usage: obj.generate(num_words, text_seed, random_seed) and returns: generated, _weighted_choice