code: def display_hook(fn):
      """
      A decorator to wrap display hooks that return a MIME bundle or None.
      Additionally it handles adding output to the notebook archive, saves
      files specified with the output magic and handles tracebacks.
      """
  
      @wraps(fn)
      def wrapped(element):
          global FULL_TRACEBACK  # noqa: PLW0603
          if Store.current_backend is None:
              return {}, {}
  
          try:
              max_frames = OutputSettings.options["max_frames"]
              mimebundle = fn(element, max_frames=max_frames)
              if mimebundle is None:
                  return {}, {}
              mime_data, mime_metadata = mimebundle
              if MIME_TYPES["js"] in mime_data:
                  mime_data["text/html"] = mimebundle_to_html(mime_data)
                  del mime_data[MIME_TYPES["js"]]
  
              # Only want to add to the archive for one display hook...
              disabled_suffixes = ["png_display", "svg_display"]
              if not any(
                  fn.__name__.endswith(suffix)
                  for suffix in disabled_suffixes
              ):
                  if (
                      type(hv.archive) is not FileArchive
                      and "text/html" in mime_data
                  ):
                      hv.archive.add(
                          element, html=mime_data["text/html"]
                      )
              filename = OutputSettings.options["filename"]
              if filename:
                  Store.renderers[Store.current_backend].save(
                      element, filename
                  )
              return mime_data, mime_metadata
          except SkipRendering as e:
              if e.warn:
                  sys.stderr.write(str(e))
              return {}, {}
          except AbbreviatedException as e:
              FULL_TRACEBACK = "\n".join(
                  traceback.format_exception(
                      e.etype, e.value, e.traceback
                  )
              )
              info = dict(
                  name=e.etype.__name__,
                  message=str(e.value).replace("\n", "<br>"),
              )
              msg = "<i> [Call holoviews.ipython.show_traceback() for details]</i>"
              return {
                  "text/html": "<b>{name}</b>{msg}<br>{message}".format(
                      msg=msg, **info
                  )
              }, {}
  
          except Exception:
              raise
  
      return wrapped
  
imports: import sys
  import traceback
  from contextlib import contextmanager
  from functools import wraps
  import IPython
  from IPython import get_ipython
  from IPython.display import HTML
  import holoviews
  from ..core import AdjointLayout, CompositeOverlay, Dimensioned, DynamicMap, Empty, GridSpace, HoloMap, Layout, NdLayout, ViewableElement
  from ..core.io import FileArchive
  from ..core.options import AbbreviatedException, SkipRendering, Store, StoreOptions
  from ..core.traversal import unique_dimkeys
  from ..core.util import mimebundle_to_html
  from ..plotting import Plot
  from ..plotting.renderer import MIME_TYPES
  from ..util.settings import OutputSettings
  from .magics import OptsMagic, OutputMagic
label_desc: Use image node_id 10 for calling a global function with example usage: display_hook(fn) and returns: wrapped, dict,  dict, mime_data,  mime_metadata, dict,  dict, dict,  dict, dict,  dict