code: def test_timeout():
      def fn(x):
          return [time.sleep(1), x][1]
  
      space = hp.choice("x", range(20))
  
      start_time_1 = timer()
      fmin(
          fn=fn,
          space=space,
          max_evals=10,
          timeout=1,
          algo=rand.suggest,
          return_argmin=False,
          rstate=np.random.default_rng(0),
      )
      end_time_1 = timer()
      assert (end_time_1 - start_time_1) < 2
      assert (end_time_1 - start_time_1) > 0.9
  
      start_time_5 = timer()
      fmin(
          fn=fn,
          space=space,
          max_evals=10,
          timeout=5,
          algo=rand.suggest,
          return_argmin=False,
          rstate=np.random.default_rng(0),
      )
      end_time_5 = timer()
      assert (end_time_5 - start_time_5) < 6
      assert (end_time_5 - start_time_5) > 4.9
  
imports: import unittest
  import numpy
  from timeit import default_timer
  import time
  from hyperopt.early_stop import no_progress_loss
  from hyperopt.fmin import generate_trials_to_calculate
  import pytest
  from hyperopt import fmin, rand, tpe, hp, Trials, exceptions, space_eval, STATUS_FAIL, STATUS_OK
  from hyperopt.base import JOB_STATE_ERROR
label_desc: Use image node_id 9 for calling a global function with example usage: test_timeout() and returns: list