code: def get_file_format_extension(resource_name: Text) -> Text:
      """Get the file extension based on training data format. It supports both a folder and
      a file, and tries to guess the format as follows:
  
      - if the resource is a file and has a known format, return this format's extension
      - if the resource is a folder and all the resources have the
        same known format, return it's extension
      - otherwise, default to DEFAULT_FILE_FORMAT (yml).
  
      Args:
          resource_name: The name of the resource, can be a file or a folder.
  
      Returns:
          The resource file format.
      """  # noqa: E501
      from rasa.shared.nlu.training_data import loading
  
      if resource_name is None or not os.path.exists(resource_name):
          raise AttributeError(
              f"Resource '{resource_name}' does not exist."
          )
  
      files = rasa.shared.utils.io.list_files(resource_name)
  
      file_formats = list(map(lambda f: loading.guess_format(f), files))
  
      if not file_formats:
          return rasa.shared.data.yaml_file_extension()
  
      known_file_formats = {
          loading.RASA_YAML: rasa.shared.data.yaml_file_extension()
      }
      fformat = file_formats[0]
      if all(f == fformat for f in file_formats):
          return known_file_formats.get(
              fformat, rasa.shared.data.yaml_file_extension()
          )
  
      return rasa.shared.data.yaml_file_extension()
  
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 3 for calling a global function with example usage: get_file_format_extension(resource_name) and returns: rasa, rasa, known_file_formats