code: def _avg_confidence_per_tag(
      relevant_tags: List[Text], relevant_confidences: List[float]
  ) -> Dict[Text, float]:
      confidences_per_tag = defaultdict(list)
  
      for tag, confidence in zip(relevant_tags, relevant_confidences):
          confidences_per_tag[tag].append(confidence)
  
      avg_confidence_per_tag = {}
      for tag, confidences in confidences_per_tag.items():
          avg_confidence_per_tag[tag] = round(
              sum(confidences) / len(confidences), 2
          )
  
      return avg_confidence_per_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 14 for calling a global function with example usage: _avg_confidence_per_tag(relevant_tags, relevant_confidences) and returns: avg_confidence_per_tag