class_docstr: ABC for Language Models.
  
  Cannot be directly instantiated itself.
docstr: Creates new LanguageModel.
  
  :param vocabulary: If provided, this vocabulary will be used instead
      of creating a new one when training.
  :type vocabulary: `nltk.lm.Vocabulary` or None
  :param counter: If provided, use this object to count ngrams.
  :type counter: `nltk.lm.NgramCounter` or None
  :param ngrams_fn: If given, defines how sentences in training text are turned to ngram
      sequences.
  :type ngrams_fn: function or None
  :param pad_fn: If given, defines how sentences in training text are padded.
  :type pad_fn: function or None
docstr_tok: ["Creates","new","LanguageModel",".",":","param","vocabulary",":","If","provided",",","this","vocabulary","will","be","used","instead","of","creating","a","new","one","when","training",".",":","type","vocabulary",":","`","nltk.lm.Vocabulary","`","or","None",":","param","counter",":","If","provided",",","use","this","object","to","count","ngrams",".",":","type","counter",":","`","nltk.lm.NgramCounter","`","or","None",":","param","ngrams_fn",":","If","given",",","defines","how","sentences","in","training","text","are","turned","to","ngram","sequences",".",":","type","ngrams_fn",":","function","or","None",":","param","pad_fn",":","If","given",",","defines","how","sentences","in","training","text","are","padded",".",":","type","pad_fn",":","function","or","None"]
code: def __init__(self, order, vocabulary=None, counter=None):
      """Creates new LanguageModel.
  
      :param vocabulary: If provided, this vocabulary will be used instead
          of creating a new one when training.
      :type vocabulary: `nltk.lm.Vocabulary` or None
      :param counter: If provided, use this object to count ngrams.
      :type counter: `nltk.lm.NgramCounter` or None
      :param ngrams_fn: If given, defines how sentences in training text are turned to ngram
          sequences.
      :type ngrams_fn: function or None
      :param pad_fn: If given, defines how sentences in training text are padded.
      :type pad_fn: function or None
      """
      self.order = order
      if vocabulary and not isinstance(vocabulary, Vocabulary):
          warnings.warn(
              f"The `vocabulary` argument passed to {self.__class__.__name__!r} "
              "must be an instance of `nltk.lm.Vocabulary`.",
              stacklevel=3,
          )
      self.vocab = Vocabulary() if vocabulary is None else vocabulary
      self.counts = NgramCounter() if counter is None else counter
  
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 1 to create a new LanguageModel object  with example: obj = LanguageModel(order, vocabulary, counter)