code: def map_message_entities(
      message: "Message", attribute_key: Text = ENTITY_ATTRIBUTE_TYPE
  ) -> List[Tuple[int, int, Text]]:
      """Maps the entities of the given message to their start, end, and tag values.
  
      Args:
          message: the message
          attribute_key: key of tag value to use
  
      Returns: a list of start, end, and tag value tuples
      """
  
      def convert_entity(
          entity: Dict[Text, Any]
      ) -> Tuple[int, int, Text]:
          return (
              entity[ENTITY_ATTRIBUTE_START],
              entity[ENTITY_ATTRIBUTE_END],
              entity.get(attribute_key) or NO_ENTITY_TAG,
          )
  
      entities = [
          convert_entity(entity) for entity in message.get(ENTITIES, [])
      ]
  
      # entities is a list of tuples (start, end, tag value).
      # filter out all entities with tag value == NO_ENTITY_TAG.
      tag_value_idx = 2
      return [
          entity
          for entity in entities
          if entity[tag_value_idx] != NO_ENTITY_TAG
      ]
  
imports: import logging
  import operator
  from collections import defaultdict, Counter
  from typing import List, Tuple, Text, Optional, Dict, Any, TYPE_CHECKING
  from rasa.nlu.constants import TOKENS_NAMES, BILOU_ENTITIES, BILOU_ENTITIES_GROUP, BILOU_ENTITIES_ROLE
  from rasa.shared.nlu.constants import TEXT, ENTITIES, ENTITY_ATTRIBUTE_START, ENTITY_ATTRIBUTE_END, ENTITY_ATTRIBUTE_TYPE, ENTITY_ATTRIBUTE_GROUP, ENTITY_ATTRIBUTE_ROLE, NO_ENTITY_TAG
label_desc: Use image node_id 8 for calling a global function with example usage: map_message_entities(message, attribute_key) and returns: unknown, entity,  entity,  unknown