code: def find_entities_in_training_example(
      example: Text,
  ) -> List[Dict[Text, Any]]:
      """Extracts entities from an annotated utterance.
  
      Args:
          example: Annotated utterance.
  
      Returns:
          Extracted entities.
      """
      entities = []
      offset = 0
  
      for match in re.finditer(ENTITY_REGEX, example):
          logger.debug(f"Entity annotation regex match: {match}")
          if (
              match.groupdict()[GROUP_ENTITY_DICT]
              or match.groupdict()[GROUP_ENTITY_TYPE]
          ):
              # Text is annotated with a single entity
              entity_attributes = extract_entity_attributes(match)
  
              start_index = match.start() - offset
              end_index = start_index + len(entity_attributes.text)
              offset += len(match.group(0)) - len(
                  entity_attributes.text
              )
  
              entity = rasa.shared.nlu.training_data.util.build_entity(
                  start_index,
                  end_index,
                  entity_attributes.value,
                  entity_attributes.type,
                  entity_attributes.role,
                  entity_attributes.group,
              )
              entities.append(entity)
          else:
              # Text is annotated with multiple entities for the same text
              entity_text = match.groupdict()[GROUP_ENTITY_TEXT]
  
              start_index = match.start() - offset
              end_index = start_index + len(entity_text)
              offset += len(match.group(0)) - len(entity_text)
  
              for match_inner in re.finditer(
                  SINGLE_ENTITY_DICT,
                  match.groupdict()[GROUP_ENTITY_DICT_LIST],
              ):
                  entity_attributes = (
                      extract_entity_attributes_from_dict(
                          entity_text=entity_text, match=match_inner
                      )
                  )
  
                  entity = (
                      rasa.shared.nlu.training_data.util.build_entity(
                          start_index,
                          end_index,
                          entity_attributes.value,
                          entity_attributes.type,
                          entity_attributes.role,
                          entity_attributes.group,
                      )
                  )
                  entities.append(entity)
  
      return entities
  
file_path: rasa/rasa/shared/nlu/training_data/entities_parser.py
imports: import re
  from json import JSONDecodeError
  from typing import Text, List, Dict, Match, Optional, NamedTuple, Any
  import logging
  import rasa.shared.nlu.training_data.util
  from rasa.shared.constants import DOCS_URL_TRAINING_DATA_NLU
  from rasa.shared.exceptions import InvalidEntityFormatException
  from rasa.shared.nlu.constants import ENTITY_ATTRIBUTE_VALUE, ENTITY_ATTRIBUTE_TYPE, ENTITY_ATTRIBUTE_GROUP, ENTITY_ATTRIBUTE_ROLE
  from rasa.shared.nlu.training_data.message import Message
label_desc: Use image node_id 1 for calling a global function with example usage: find_entities_in_training_example(example) and returns: entities