code: def _qt_safe_window(
      *,
      splash="figure.splash",
      window="figure.plotter.app_window",
      always_close=True,
  ):
      def dec(meth, splash=splash, always_close=always_close):
          @functools.wraps(meth)
          def func(self, *args, **kwargs):
              close_splash = always_close
              error = False
              try:
                  meth(self, *args, **kwargs)
              except Exception:
                  close_splash = error = True
                  raise
              finally:
                  for attr, do_close in (
                      (splash, close_splash),
                      (window, error),
                  ):
                      if attr is None or not do_close:
                          continue
                      parent = self
                      name = attr.split(".")[-1]
                      try:
                          for n in attr.split(".")[:-1]:
                              parent = getattr(parent, n)
                          if name:
                              widget = getattr(parent, name, False)
                          else:  # empty string means "self"
                              widget = parent
                          if widget:
                              widget.close()
                          del widget
                      except Exception:
                          pass
                      finally:
                          try:
                              delattr(parent, name)
                          except Exception:
                              pass
  
          return func
  
      return dec
  
imports: import collections.abc
  import functools
  import os
  import platform
  import signal
  import sys
  from colorsys import rgb_to_hls
  from contextlib import contextmanager
  from ctypes import c_char_p, c_void_p, cdll
  from pathlib import Path
  import numpy
  from ...fixes import _compare_version
  from ...utils import _check_qt_version, _validate_type, logger, warn
  from ..utils import _get_cmap
label_desc: Use image node_id 16 for calling a global function with example usage: _qt_safe_window() and returns: dec, func