code: def entity_label_to_tags(
      model_predictions: Dict[Text, Any],
      entity_tag_specs: List["EntityTagSpec"],
      bilou_flag: bool = False,
      prediction_index: int = 0,
  ) -> Tuple[Dict[Text, List[Text]], Dict[Text, List[float]]]:
      """Convert the output predictions for entities to the actual entity tags.
  
      Args:
          model_predictions: the output predictions using the entity tag indices
          entity_tag_specs: the entity tag specifications
          bilou_flag: if 'True', the BILOU tagging schema was used
          prediction_index: the index in the batch of predictions
              to use for entity extraction
  
      Returns:
          A map of entity tag type, e.g. entity, role, group, to actual entity tags and
          confidences.
      """
      predicted_tags = {}
      confidence_values = {}
  
      for tag_spec in entity_tag_specs:
          predictions = model_predictions[f"e_{tag_spec.tag_name}_ids"]
          confidences = model_predictions[
              f"e_{tag_spec.tag_name}_scores"
          ]
  
          if not np.any(predictions):
              continue
  
          confidences = [
              float(c) for c in confidences[prediction_index]
          ]
          tags = [
              tag_spec.ids_to_tags[p]
              for p in predictions[prediction_index]
          ]
  
          if bilou_flag:
              (
                  tags,
                  confidences,
              ) = rasa.nlu.utils.bilou_utils.ensure_consistent_bilou_tagging(
                  tags, confidences
              )
  
          predicted_tags[tag_spec.tag_name] = tags
          confidence_values[tag_spec.tag_name] = confidences
  
      return predicted_tags, confidence_values
  
imports: from pathlib import Path
  import numpy
  from typing import Optional, Text, Dict, Any, Union, List, Tuple, TYPE_CHECKING
  import rasa.shared.utils.common
  import rasa.shared.utils.io
  import rasa.nlu.utils.bilou_utils
  from rasa.shared.constants import NEXT_MAJOR_VERSION_FOR_DEPRECATIONS
  from rasa.nlu.constants import NUMBER_OF_SUB_TOKENS
  import rasa.utils.io
  from rasa.utils.tensorflow.constants import LOSS_TYPE, RANKING_LENGTH, RENORMALIZE_CONFIDENCES, SIMILARITY_TYPE, EVAL_NUM_EXAMPLES, EVAL_NUM_EPOCHS, EPOCHS, SOFTMAX, MARGIN, AUTO, INNER, COSINE, SEQUENCE, CROSS_ENTROPY, CONSTRAIN_SIMILARITIES, MODEL_CONFIDENCE, TOLERANCE, CHECKPOINT_MODEL
  from rasa.utils.tensorflow.callback import RasaTrainingLogger, RasaModelCheckpoint
  from rasa.utils.tensorflow.data_generator import RasaBatchDataGenerator
  from rasa.utils.tensorflow.model_data import RasaModelData
  from rasa.shared.nlu.constants import SPLIT_ENTITIES_BY_COMMA
  from rasa.shared.exceptions import InvalidConfigException
label_desc: Use image node_id 9 for calling a global function with example usage: entity_label_to_tags(model_predictions, entity_tag_specs, bilou_flag, prediction_index) and returns: predicted_tags,  confidence_values