code: def trial_to_tuple(trial, space):
      """Extract a parameter tuple from a `orion.core.worker.trial.Trial`.
  
      The order within the tuple is dictated by the defined
      `orion.algo.space.Space` object.
      """
      params = flatten(trial.params)
      trial_keys = set(params.keys())
      space_keys = set(space.keys())
      if trial_keys != space_keys:
          raise ValueError(
              f"The trial {trial.id} has wrong params:\n"
              f"Trial params: {sorted(trial_keys)}\n"
              f"Space dims: {sorted(space_keys)}"
          )
      return tuple(params[name] for name in space.keys())
  
imports: from orion.core.utils.flatten import flatten
  from orion.core.worker.trial import Trial
label_desc: Use image node_id 1 for calling a global function with example usage: trial_to_tuple(trial, space) and returns: tuple