code: def ngramize(
      items: List[str], ngram_range=(1, 1), doc: str = None
  ) -> Generator[List[str], Any, None]:
      """
      Make ngrams from a list of tokens/lemmas
      :param items: list of tokens, lemmas or other strings to form ngrams
      :param ngram_range: range for producing ngrams, ex. for unigrams + bigrams should be set to
      (1, 2), for bigrams only should be set to (2, 2)
      :return: ngrams (as strings) generator
      """
  
      ngrams = []
      ranges = [
          (0, i) for i in range(ngram_range[0], ngram_range[1] + 1)
      ]
      for r in ranges:
          ngrams += list(zip(*[items[j:] for j in range(*r)]))
  
      formatted_ngrams = [" ".join(item) for item in ngrams]
      if doc is not None:
          doc_lower = doc.lower()
          formatted_ngrams = [
              ngram
              for ngram in formatted_ngrams
              if (ngram in doc or ngram in doc_lower)
          ]
  
      yield formatted_ngrams
  
imports: import re
  from typing import List, Generator, Any
label_desc: Use image node_id 2 for calling a global function with example usage: ngramize(items, ngram_range, doc) without return types