code: def test_early_stop():
      trials = Trials()
  
      # basic stop after 100 trials
      def stop(trial, count=0):
          return count + 1 >= 100, [count + 1]
  
      fmin(
          fn=lambda x: x,
          space=hp.uniform("x", -5, 5),
          algo=rand.suggest,
          max_evals=500,
          trials=trials,
          early_stop_fn=stop,
      )
  
      assert len(trials) == 100
  
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 13 for calling a global function with example usage: test_early_stop() and returns: unknown,  list