code: def transform_entity_synonyms(
      synonyms: List[Dict[Text, Any]],
      known_synonyms: Optional[Dict[Text, Any]] = None,
  ) -> Dict[Text, Any]:
      """Transforms the entity synonyms into a text->value dictionary."""
      entity_synonyms = known_synonyms if known_synonyms else {}
      for s in synonyms:
          if "value" in s and "synonyms" in s:
              for synonym in s["synonyms"]:
                  entity_synonyms[synonym] = s["value"]
      return entity_synonyms
  
imports: import json
  import logging
  import os
  import re
  from typing import Any, Dict, Optional, Text, Match, List
  import scipy.sparse
  from rasa.shared.nlu.constants import ENTITIES, EXTRACTOR, PRETRAINED_EXTRACTORS, ENTITY_ATTRIBUTE_START, ENTITY_ATTRIBUTE_END, ENTITY_ATTRIBUTE_VALUE, ENTITY_ATTRIBUTE_TYPE, ENTITY_ATTRIBUTE_ROLE, ENTITY_ATTRIBUTE_GROUP
  from rasa.shared.constants import UTTER_PREFIX
  import rasa.shared.utils.io
  import rasa.shared.data
label_desc: Use image node_id 1 for calling a global function with example usage: transform_entity_synonyms(synonyms, known_synonyms) and returns: entity_synonyms