code: def _install_stacktrace_on_sigusr1() -> None:
      """Install a SIGUSR1 handler that prints a stack trace to stderr."""
      if not hasattr(signal, "SIGUSR1"):
          return
  
      # Signal handlers can only be registered on main threads.
      if threading.current_thread() is not threading.main_thread():
          return
  
      old_handler = None
  
      def stacktrace_on_sigusr1(signum: Any, frame: Any) -> None:
          traceback.print_stack(frame, file=sys.stderr)
          # old_handler may be None, SIG_IGN, or SIG_DFL.  It happens that SIG_DFL would be a noop for
          # SIGUSR1 so we don't have to worry about that case.
          if callable(old_handler):
              old_handler(signum, frame)
  
      old_handler = signal.signal(signal.SIGUSR1, stacktrace_on_sigusr1)
  
imports: import logging
  import pathlib
  import signal
  import sys
  import threading
  import traceback
  import types
  from typing import Any, Dict, Optional, Union
  import appdirs
  import determined
  from determined import core, tensorboard
  from determined.common import api, constants, storage, util
  from determined.common.api import certs
label_desc: Use image node_id 1 for calling a global function with example usage: _install_stacktrace_on_sigusr1() without return types