code: def get_metric_fields(self, obj):
      metric_list = self.context.get("metric_fields", [])
      result = dict()
  
      if not isinstance(obj.metrics, dict) or len(metric_list) == 0:
          return result
  
      for metric in metric_list:
          metric_name = metric.split("$")[0]
          max_flag = metric.split("$")[1]
  
          if metric_name not in obj.metrics["metric_list"]:
              continue
  
          # Get the max and min value
          max = 0
          min = 0
          for i, m in enumerate(obj.metrics["evaluation"][metric_name]):
              current_value = m["value"]
  
              if i == 0:
                  max = current_value
                  min = current_value
                  continue
  
              if current_value > max:
                  max = current_value
  
              if current_value < min:
                  min = current_value
  
          if max_flag == "1":
              result[metric] = max
          else:
              result[metric] = min
  
      return result
  
file_path: modelchimp/modelchimp/serializers/experiment.py
imports: from rest_framework import serializers
  from modelchimp.models.experiment import Experiment
  from django.utils import timezone
label_desc: Use image node_id 6 for calling the ExperimentSerializer obj's underlying member method code with example usage: obj.get_metric_fields(obj) and returns: result, result