code: def generate_trials(exp, trials):
      """Generate trials for each item in trials.
  
      Items of trials can be either dictionary of valid hyperparameters based on exp.space and status
      or `None`.
  
      If status not provided, 'new' is used by default.
  
      For items that are `None`, trials are suggested with exp.suggest().
      """
      for trial_config in trials:
          trial_config = copy.deepcopy(trial_config)
          status = (
              trial_config.pop("status", None) if trial_config else None
          )
          if trial_config:
              trial = exp.insert(params=trial_config)
          else:
              with exp.suggest() as trial:
                  # Releases suggested trial when leaving with-clause.
                  pass
  
          if status is not None:
              exp._experiment._storage.set_trial_status(
                  trial,
                  status,
                  heartbeat=trial.submit_time
                  if status == "reserved"
                  else None,
              )
          else:
              exp._experiment._storage.set_trial_status(
                  trial,
                  "reserved",
                  heartbeat=trial.submit_time,
              )
  
file_path: orion/src/orion/testing/evc.py
imports: import contextlib
  import copy
  from orion.client import build_experiment, get_experiment
  from orion.core.io.space_builder import DimensionBuilder
label_desc: Use image node_id 2 for calling a global function with example usage: generate_trials(exp, trials) without return types