code: def test_train_and_process(
      create_or_load_extractor: Callable[..., RegexEntityExtractor],
      config: Dict[Text, Any],
      text: Text,
      lookup: List[Dict[Text, List[Text]]],
      expected_entities: List[Dict[Text, Any]],
      test_loading: bool,
  ):
      message = Message(data={TEXT: text})
      if test_loading:
          message_copy = copy.deepcopy(message)
  
      training_data = TrainingData()
      training_data.lookup_tables = lookup
      training_data.training_examples = [
          Message(
              data={
                  TEXT: "Hi Max!",
                  INTENT: "greet",
                  ENTITIES: [{"entity": "person", "value": "Max"}],
              }
          ),
          Message(
              data={
                  TEXT: "I live in Berlin",
                  INTENT: "inform",
                  ENTITIES: [{"entity": "city", "value": "Berlin"}],
              }
          ),
      ]
  
      entity_extractor = create_or_load_extractor(config)
      entity_extractor.train(training_data)
      entity_extractor.process([message])
      entities = message.get(ENTITIES)
      assert entities == expected_entities
  
      if test_loading:
          loaded_entity_extractor = create_or_load_extractor(
              config, load=True
          )
          loaded_entity_extractor.process([message_copy])
          loaded_entity_extractor.patterns == entity_extractor.patterns
  
file_path: rasa/tests/nlu/extractors/test_regex_entity_extractor.py
imports: import copy
  from rasa.engine.graph import ExecutionContext
  from rasa.engine.storage.storage import ModelStorage
  from typing import Any, Text, Dict, List, Callable
  import pytest
  from rasa.engine.storage.resource import Resource
  from rasa.shared.nlu.training_data.training_data import TrainingData
  from rasa.shared.nlu.training_data.message import Message
  from rasa.shared.nlu.constants import ENTITIES, ENTITY_ATTRIBUTE_TYPE, ENTITY_ATTRIBUTE_VALUE, ENTITY_ATTRIBUTE_START, ENTITY_ATTRIBUTE_END, TEXT, INTENT, EXTRACTOR
  from rasa.nlu.extractors.regex_entity_extractor import RegexEntityExtractor
label_desc: Use image node_id 2 for calling a global function with example usage: test_train_and_process(create_or_load_extractor, config, text, lookup, expected_entities, test_loading) without return types