code: def build_benchmark_response(
      benchmark: Benchmark,
      assessment: str = None,
      task: str = None,
      algorithms: List[str] = None,
  ):
      """
      Build the response representing an experiment response object according to the API
      specification.
  
      Parameters
      ----------
      benchmark: Benchmark
          The benchmark to return to the API
      assessment: str
          The assessment analysis to return
      task: str
          The task analysis to return
      algorithms: list
          The list of algorithm names to include in the analysis.
  
      Returns
      -------
      A JSON-serializable benchmark response object representing the given benchmark.
      """
  
      def convert_plotly_to_json(analysis):
          for study_name, study_analysis in analysis.items():
              for task_name, task_analysis in study_analysis.items():
                  analysis[study_name][task_name] = {
                      key: figure.to_json()
                      for key, figure in task_analysis.items()
                  }
          return analysis
  
      data = {
          "name": benchmark.name,
          "algorithms": benchmark.algorithms,
          "tasks": [
              task.configuration
              for task in benchmark.targets[0]["task"]
          ],
          "assessments": [
              assessment.configuration
              for assessment in benchmark.targets[0]["assess"]
          ],
          "analysis": convert_plotly_to_json(
              benchmark.analysis(
                  assessment=assessment,
                  task=task,
                  algorithms=algorithms,
              )
          ),
      }
  
      return data
  
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 5 for calling a global function with example usage: build_benchmark_response(benchmark, assessment, task, algorithms) and returns: data, analysis