code: def _collect_regex_features(
      training_data: TrainingData, use_only_entities: bool = False
  ) -> List[Dict[Text, Text]]:
      """Get regex features from training data.
  
      Args:
          training_data: The training data
          use_only_entities: If True only regex features with a name equal to a entity
            are considered.
  
      Returns:
          Regex features.
      """
      if not use_only_entities:
          return training_data.regex_features
  
      return [
          regex
          for regex in training_data.regex_features
          if regex["name"] in training_data.entities
      ]
  
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 4 for calling a global function with example usage: _collect_regex_features(training_data, use_only_entities) and returns: unknown, training_data