code: def build_trial_response(trial: Trial) -> dict:
      """
      Build the response representing a trial according to the API specification.
  
      Parameters
      ----------
      trial: Trial
          The trial to return for the API.
  
      Returns
      -------
      A JSON-serializable dict representing the given trial.
  
      """
      return {
          "id": trial.id,
          "submitTime": str(trial.submit_time),
          "startTime": str(trial.start_time),
          "endTime": str(trial.end_time),
          "parameters": trial.params,
          "objective": trial.objective.value
          if trial.status == "completed"
          else None,
          "statistics": {
              statistic.name: statistic.value
              for statistic in trial.statistics
          },
          "status": trial.status,
      }
  
file_path: orion/src/orion/serving/responses.py
imports: from typing import List
  from orion.benchmark import Benchmark
  from orion.core.worker.experiment import Experiment
  from orion.core.worker.trial import Trial
label_desc: Use image node_id 1 for calling a global function with example usage: build_trial_response(trial) and returns: dict