code: def get_format_implementation(ext, format_name=None):
      """Return the implementation for the desired format"""
      # remove pre-extension if any
      ext = "." + ext.split(".")[-1]
  
      formats_for_extension = []
      for fmt in JUPYTEXT_FORMATS:
          if fmt.extension == ext:
              if fmt.format_name == format_name or not format_name:
                  return fmt
              formats_for_extension.append(fmt.format_name)
  
      if formats_for_extension:
          raise JupytextFormatError(
              "Format '{}' is not associated to extension '{}'. "
              "Please choose one of: {}.".format(
                  format_name, ext, ", ".join(formats_for_extension)
              )
          )
      raise JupytextFormatError(
          f"No format associated to extension '{ext}'"
      )
  
imports: import os
  import re
  import warnings
  import nbformat
  import yaml
  from .cell_reader import DoublePercentScriptCellReader, HydrogenCellReader, LightScriptCellReader, MarkdownCellReader, RMarkdownCellReader, RScriptCellReader, SphinxGalleryScriptCellReader
  from .cell_to_text import BareScriptCellExporter, DoublePercentCellExporter, HydrogenCellExporter, LightScriptCellExporter, MarkdownCellExporter, RMarkdownCellExporter, RScriptCellExporter, SphinxGalleryCellExporter
  from .header import header_to_metadata_and_cell, insert_or_test_version_number
  from .languages import _COMMENT_CHARS, _SCRIPT_EXTENSIONS, same_language
  from .magics import is_magic
  from .metadata_filter import metadata_filter_as_string
  from .myst import MYST_FORMAT_NAME, is_myst_available, matches_mystnb, myst_extensions, myst_version
  from .pandoc import is_pandoc_available, pandoc_version
  from .stringparser import StringParser
  from .version import __version__
label_desc: Use image node_id 1 for calling a global function with example usage: get_format_implementation(ext, format_name) and returns: fmt