code: def extract_patterns(
      training_data: TrainingData,
      use_lookup_tables: bool = True,
      use_regexes: bool = True,
      use_only_entities: bool = False,
      use_word_boundaries: bool = True,
  ) -> List[Dict[Text, Text]]:
      r"""Extract a list of patterns from the training data.
  
      The patterns are constructed using the regex features and lookup tables defined
      in the training data.
  
      Args:
          training_data: The training data.
          use_only_entities: If True only lookup tables and regex features with a name
            equal to a entity are considered.
          use_regexes: Boolean indicating whether to use regex features or not.
          use_lookup_tables: Boolean indicating whether to use lookup tables or not.
          use_word_boundaries: Boolean indicating whether to use `\b` around the lookup
              table regex expressions
  
      Returns:
          The list of regex patterns.
      """
      if (
          not training_data.lookup_tables
          and not training_data.regex_features
      ):
          return []
  
      patterns = []
  
      if use_regexes:
          patterns.extend(
              _collect_regex_features(training_data, use_only_entities)
          )
      if use_lookup_tables:
          patterns.extend(
              _convert_lookup_tables_to_regex(
                  training_data, use_only_entities, use_word_boundaries
              )
          )
  
      # validate regexes, raise Error when invalid
      for pattern in patterns:
          try:
              re.compile(pattern["pattern"])
          except re.error:
              raise InvalidConfigException(
                  f"Model training failed. '{pattern['pattern']}' "
                  "is not a valid regex. Please update your nlu "
                  f"training data configuration at {pattern}."
              )
  
      return patterns
  
file_path: rasa/rasa/nlu/utils/pattern_utils.py
imports: import re
  from typing import Dict, List, Text, Union
  import rasa.shared.utils.io
  from rasa.shared.nlu.training_data.training_data import TrainingData
  from rasa.shared.exceptions import InvalidConfigException
label_desc: Use image node_id 5 for calling a global function with example usage: extract_patterns(training_data, use_lookup_tables, use_regexes, use_only_entities, use_word_boundaries) and returns: patterns, list