code: def timeout(time: int = 30):
      """
      Raise a timeout if a function does not return in time `time`.
  
      Use as a context manager, so that the signal class can reset it's alarm for
      `SIGALARM`
  
      :param int time:
          Time in seconds to wait for timeout. Default is 30 seconds.
      """
      assert time >= 0, "Time specified in timeout must be nonnegative."
  
      def _handler(signum, frame):
          raise TimeoutError
  
      signal.signal(signal.SIGALRM, _handler)
      signal.alarm(time)
  
      try:
          yield
      except TimeoutError as e:
          raise e
      finally:
          signal.signal(signal.SIGALRM, signal.SIG_IGN)
  
imports: import os
  import unittest
  import contextlib
  import tempfile
  import shutil
  import io
  import signal
  from typing import Tuple, Dict, Any
  from parlai.core.opt import Opt
  import parlai.utils.logging
  from parlai.utils.io import PathManager
  from pytest_regressions.data_regression import DataRegressionFixture
label_desc: Use image node_id 20 for calling a global function with example usage: timeout(time) without return types