code: def preferred_format(incomplete_format, preferred_formats):
      """Return the preferred format for the given extension"""
      incomplete_format = long_form_one_format(incomplete_format)
      if "format_name" in incomplete_format:
          return incomplete_format
  
      for fmt in long_form_multiple_formats(preferred_formats):
          if (
              (
                  incomplete_format["extension"] == fmt["extension"]
                  or (
                      fmt["extension"] == ".auto"
                      and incomplete_format["extension"]
                      not in [".md", ".markdown", ".Rmd", ".ipynb"]
                  )
              )
              and incomplete_format.get("suffix")
              == fmt.get("suffix", incomplete_format.get("suffix"))
              and incomplete_format.get("prefix")
              == fmt.get("prefix", incomplete_format.get("prefix"))
          ):
              fmt.update(incomplete_format)
              return fmt
  
      return incomplete_format
  
imports: import json
  import os
  import warnings
  import yaml
  from traitlets import Bool, Dict, Enum, Float, List, Unicode, Union
  from traitlets.config import Configurable
  from traitlets.config.loader import PyFileConfigLoader
  from traitlets.traitlets import TraitError
  from .formats import NOTEBOOK_EXTENSIONS, long_form_multiple_formats, long_form_one_format, short_form_multiple_formats
label_desc: Use image node_id 1 for calling a global function with example usage: preferred_format(incomplete_format, preferred_formats) and returns: incomplete_format, incomplete_format, fmt