code: def test_trial_attachments():
      exp_key = "A"
      with TempMongo() as tm:
          mj = tm.mongo_jobs("foo")
          trials = MongoTrials(
              tm.connection_string("foo"), exp_key=exp_key
          )
  
          space = hp.uniform("x", -10, 10)
          max_evals = 3
          fmin_thread = threading.Thread(
              target=fmin_thread_fn, args=(space, trials, max_evals)
          )
          fmin_thread.start()
  
          mw = MongoWorker(
              mj=mj, logfilename=None, workdir="mongoexp_test_dir"
          )
          n_jobs = max_evals
          while n_jobs:
              try:
                  mw.run_one(
                      "hostname", 10.0, erase_created_workdir=True
                  )
                  print("worker: ran job")
              except Exception as exc:
                  print(f"worker: encountered error : {str(exc)}")
                  traceback.print_exc()
              n_jobs -= 1
          fmin_thread.join()
          all_trials = MongoTrials(tm.connection_string("foo"))
  
          assert len(all_trials) == max_evals
          assert (
              trials.count_by_state_synced(JOB_STATE_DONE) == max_evals
          )
          assert (
              trials.count_by_state_unsynced(JOB_STATE_DONE)
              == max_evals
          )
  
imports: import pickle
  import os
  import signal
  import subprocess
  import sys
  import traceback
  import threading
  import time
  import unittest
  import numpy
  import nose
  import nose.plugins.skip
  from hyperopt.base import JOB_STATE_DONE, STATUS_OK
  from hyperopt.mongoexp import parse_url
  from hyperopt.mongoexp import MongoTrials
  from hyperopt.mongoexp import MongoWorker
  from hyperopt.mongoexp import ReserveTimeout
  from hyperopt.mongoexp import as_mongo_str
  from hyperopt.mongoexp import main_worker_helper
  from hyperopt.mongoexp import MongoJobs
  from hyperopt.fmin import fmin
  from hyperopt import hp, rand
  import hyperopt.tests.test_base
  from hyperopt.tests.unit.test_domains import gauss_wave2
label_desc: Use image node_id 14 for calling a global function with example usage: test_trial_attachments() without return types