code: def v1_study_trial_metrics(request, study_name, trial_id):
      if request.method == "POST":
          training_step_string = request.POST.get("training_step", "1")
          training_step = int(training_step_string)
          objective_value_string = request.POST.get(
              "objective_value", "1.0"
          )
          objective_value = float(objective_value_string)
  
          data = {
              "training_step": training_step,
              "objective_value": objective_value,
          }
          url = "http://127.0.0.1:{}/suggestion/v1/studies/{}/trials/{}/metrics".format(
              request.META.get("SERVER_PORT"), study_name, trial_id
          )
          response = requests.post(url, json=data)
          messages.info(request, response.content)
          return HttpResponseRedirect(request.META.get("HTTP_REFERER"))
      else:
          return JsonResponse({"error": "Unsupported http method"})
  
imports: from __future__ import unicode_literals
  import json
  import requests
  import platform
  import six
  from django.contrib import messages
  from django.shortcuts import redirect
  from django.http import HttpResponse
  from django.views.decorators.csrf import csrf_exempt
  from django.http import JsonResponse
  from django.http import HttpResponseRedirect
  from django.urls import reverse
  from django.http import Http404
  from django.shortcuts import get_object_or_404
  from django.shortcuts import render
  from django.shortcuts import render_to_response
  from django.conf import settings
  from django import forms
  from django.contrib.admin.views.decorators import staff_member_required
  from django.contrib.auth.decorators import login_required
  from suggestion.models import Study
  from suggestion.models import Trial
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: HttpResponseRedirect, JsonResponse