code: def v1_study_trial_metrics(request, study_name, trial_id):
      # Create the trial metric
      if request.method == "POST":
          data = json.loads(request.body)
          training_step = data["training_step"]
          objective_value = data["objective_value"]
  
          trial_metric = TrialMetric.create(
              trial_id, training_step, objective_value
          )
          return JsonResponse({"data": trial_metric.to_json()})
  
      # List the trial metrics
      elif request.method == "GET":
          trial_metrics = TrialMetric.objects.filter(trial_id=trial_id)
          response_data = [
              trial_metric.to_json() for trial_metric in trial_metrics
          ]
          return JsonResponse({"data": response_data})
      else:
          return JsonResponse({"error": "Unsupported http method"})
  
imports: from __future__ import unicode_literals
  import json
  from django.http import JsonResponse
  from django.views.decorators.csrf import csrf_exempt
  from suggestion.models import Study
  from suggestion.models import Trial
  from suggestion.models import TrialMetric
  from suggestion.algorithm.random_search import RandomSearchAlgorithm
  from suggestion.algorithm.grid_search import GridSearchAlgorithm
  from suggestion.algorithm.bayesian_optimization import BayesianOptimization
  from suggestion.algorithm.tpe import TpeAlgorithm
  from suggestion.algorithm.simulate_anneal import SimulateAnnealAlgorithm
  from suggestion.algorithm.hyperopt_random_search import HyperoptRandomSearchAlgorithm
  from suggestion.algorithm.quasi_random_search import QuasiRandomSearchAlgorithm
  from suggestion.algorithm.chocolate_random_search import ChocolateRandomSearchAlgorithm
  from suggestion.algorithm.chocolate_grid_search import ChocolateGridSearchAlgorithm
  from suggestion.algorithm.chocolate_bayes import ChocolateBayesAlgorithm
  from suggestion.algorithm.cmaes import CmaesAlgorithm
  from suggestion.algorithm.mocmaes import MocmaesAlgorithm
  from suggestion.algorithm.skopt_bayesian_optimization import SkoptBayesianOptimization
label_desc: Use image node_id 8 for calling a global function with example usage: v1_study_trial_metrics(request, study_name, trial_id) and returns: JsonResponse, JsonResponse, JsonResponse