code: def test_valid(self):
      trials = self.trials
      f = trials.insert_trial_doc
      fine = ok_trial("ID", 1, 2, 3)
  
      # --original runs fine
      f(fine)
  
      # -- take out each mandatory root key
      def knockout(key):
          rval = copy.deepcopy(fine)
          del rval[key]
          return rval
  
      for key in TRIAL_KEYS:
          self.assertRaises(InvalidTrial, f, knockout(key))
  
      # -- take out each mandatory misc key
      def knockout2(key):
          rval = copy.deepcopy(fine)
          del rval["misc"][key]
          return rval
  
      for key in TRIAL_MISC_KEYS:
          self.assertRaises(InvalidTrial, f, knockout2(key))
  
imports: import copy
  import unittest
  import numpy
  import bson
  from hyperopt.pyll import scope
  from hyperopt.base import JOB_STATE_DONE, JOB_STATE_NEW
  from hyperopt.base import TRIAL_KEYS
  from hyperopt.base import TRIAL_MISC_KEYS
  from hyperopt.base import InvalidTrial
  from hyperopt.base import miscs_to_idxs_vals
  from hyperopt.base import SONify
  from hyperopt.base import STATUS_OK
  from hyperopt.base import Trials
  from hyperopt.base import trials_from_docs
  from hyperopt.exceptions import AllTrialsFailed
label_desc: Use image node_id 2 for calling the TestTrials obj's underlying member method code with example usage: obj.test_valid() and returns: rval, rval