code: def convertResultsToTrials(self, hyperparameterSpace, results):
      trials = hyperopt.Trials()
  
      for resultIndex, result in enumerate(results):
          data = {
              "book_time": datetime.datetime.now(),
              "exp_key": None,
              "misc": {
                  "cmd": ("domain_attachment", "FMinIter_Domain"),
                  "idxs": {},
                  "tid": resultIndex,
                  "vals": {},
                  "workdir": None,
              },
              "owner": None,
              "refresh_time": datetime.datetime.now(),
              "result": {
                  "loss": result["loss"],
                  "status": result["status"],
              },
              "spec": None,
              "state": 2,
              "tid": resultIndex,
              "version": 0,
          }
  
          for param in Hyperparameter(
              hyperparameterSpace
          ).getFlatParameters():
              value = result[param.name]
              if value not in ("", None):
                  if "enum" in param.config:
                      value = param.config["enum"].index(value)
  
                  data["misc"]["idxs"][param.hyperoptVariableName] = [
                      resultIndex
                  ]
                  data["misc"]["vals"][param.hyperoptVariableName] = [
                      value
                  ]
              else:
                  data["misc"]["idxs"][param.hyperoptVariableName] = []
                  data["misc"]["vals"][param.hyperoptVariableName] = []
  
          trials.insert_trial_doc(data)
      return trials
  
imports: from hyperopt import hp
  from contextlib import contextmanager
  import re
  import functools
  import random
  import numpy
  import numpy.random
  import pkg_resources
  import tempfile
  import scipy.stats
  import os
  import math
  import hyperopt
  import datetime
  import json
  import copy
label_desc: Use image node_id 6 for calling the ATPEOptimizer obj's underlying member method code with example usage: obj.convertResultsToTrials(hyperparameterSpace, results) and returns: trials