code: def ngram_freq(
      text_docs_bow: Iterable[Iterable[str]],
      n: int = 3,
      only_n: bool = False,
  ) -> "nltk.FreqDist":  # type: ignore
      """Generates frequency distribution of "n-grams" from all of the text documents.
  
      Args:
          text_docs_bow: A list of lists of words from a document
          n: Highest `n` for n-gram sequence to include. Default is 3
          only_n: If True, will only include n-grams for specified value of `n`.
              Default is False, which also includes n-grams for all numbers leading
              up to `n`
  
      Raises:
          ValueError: `n` must be >= 2.
  
      Returns:
          freq: Dictionary which contains all identified n-grams as keys and their
              respective counts as their values
      """
      if n < 2:
          raise ValueError("'n' must be a number 2 or greater")
  
      freq = _compat["nltk"].FreqDist()  # type: ignore
      for doc in text_docs_bow:
          if only_n:
              current_ngrams = _compat["nltk"].ngrams(doc, n)  # type: ignore
              freq.update(current_ngrams)
          else:
              for num in range(2, n + 1):
                  current_ngrams = _compat["nltk"].ngrams(doc, num)  # type: ignore
                  freq.update(current_ngrams)
      return freq
  
imports: import re
  import string
  import warnings
  from types import GeneratorType
  from typing import List, Optional, Any, Iterable, TYPE_CHECKING
  import pandas
  from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer
  from data_describe.text import text_preprocessing
  from data_describe.compat import _requires, _compat
label_desc: Use image node_id 14 for calling a global function with example usage: ngram_freq(text_docs_bow, n, only_n) and returns: freq