code: def get_plot_formats(config):
      default_dpi = {"png": 80, "hires.png": 200, "pdf": 200}
      formats = []
      plot_formats = config.plot_formats
      for fmt in plot_formats:
          if isinstance(fmt, str):
              if ":" in fmt:
                  suffix, dpi = fmt.split(":")
                  formats.append((str(suffix), int(dpi)))
              else:
                  formats.append((fmt, default_dpi.get(fmt, 80)))
          elif isinstance(fmt, (tuple, list)) and len(fmt) == 2:
              formats.append((str(fmt[0]), int(fmt[1])))
          else:
              raise PlotError(
                  'invalid image format "%r" in plot_formats' % fmt
              )
      return formats
  
imports: import contextlib
  import doctest
  from io import StringIO
  import itertools
  import os
  from os.path import relpath
  from pathlib import Path
  import re
  import shutil
  import sys
  import textwrap
  import traceback
  from docutils.parsers.rst import directives, Directive
  from docutils.parsers.rst.directives.images import Image
  import jinja2
  from sphinx.errors import ExtensionError
  import matplotlib
  from matplotlib.backend_bases import FigureManagerBase
  import matplotlib.pyplot
  from matplotlib import _pylab_helpers, cbook
label_desc: Use image node_id 12 for calling a global function with example usage: get_plot_formats(config) and returns: formats