code: def tokenize_using_regex_pattern(
      text: str, pattern: re.Pattern | str
  ) -> typing.Iterator[str]:
      """
  
      >>> import re
  
      >>> text = 'iterative n-gram generation'
  
      >>> list(tokenize_using_regex_pattern(text, pattern=re.compile(r'[a-z\\-]+')))
      ['iterative', 'n-gram', 'generation']
  
      >>> list(tokenize_using_regex_pattern(text, pattern=r'[a-z\\-]+'))
      ['iterative', 'n-gram', 'generation']
  
      """
      for match in re.finditer(pattern, text):
          # The pattern find have one or more matching groups. In such a case, only the first one is
          # kept. The whole match is used if no matching groups are specified at all.
          yield match[1] if match.lastindex else match.group()
  
imports: from __future__ import annotations
  import collections
  import functools
  import itertools
  import math
  import operator
  import re
  import typing
  import unicodedata
  import pandas
  from scipy import sparse
  from river import base
label_desc: Use image node_id 2 for calling a global function with example usage: tokenize_using_regex_pattern(text, pattern) without return types