code: def _register_signal_handler(
      sig: signal.Signals, handler: Callable[[], None]
  ):
      """Registers a signal handler."""
      # We only call the handler once.
      handler = _call_once(handler)
      old_handler = signal.getsignal(sig)
  
      def _run_handler(
          sig=sig, frame=None, handler=handler, old_handler=old_handler
      ):
          handler()
          if isinstance(old_handler, Callable):
              old_handler(sig, frame)
  
      signal.signal(sig, _run_handler)
  
imports: import collections
  from concurrent import futures
  import dataclasses
  import functools
  import signal
  import subprocess
  import threading
  import time
  from typing import Any, Callable, Iterable, List, Mapping, MutableMapping, Optional, Sequence, Tuple
  from absl import logging
  from launchpad import flags
  import psutil
  import termcolor
label_desc: Use image node_id 2 for calling a global function with example usage: _register_signal_handler(sig, handler) without return types