docstr: Add the evaluation parameters event to the experiment in the db
docstr_tok: ["Add","the","evaluation","parameters","event","to","the","experiment","in","the","db"]
code: def add_metrics(self, value, epoch=None):
      """
      Add the evaluation parameters event to the experiment in the db
      """
  
      if not isinstance(self.experiment_obj.metrics, dict):
          self.experiment_obj.metrics = {
              "evaluation": {},
              "metric_list": [],
          }
  
      metric_keys = value.keys()
      existing_metric_list = self.experiment_obj.metrics["metric_list"]
      metric_data = self.experiment_obj.metrics["evaluation"]
  
      for metric in metric_keys:
          if metric in existing_metric_list:
              # Remove the existing epoch if present
              for i, d in enumerate(metric_data[metric]):
                  if d["epoch"] == epoch:
                      metric_data[metric].pop(i)
                      break
  
              metric_data[metric] += [
                  {"epoch": epoch, "value": value[metric]}
              ]
          else:
              existing_metric_list.append(metric)
              metric_data[metric] = [
                  {"epoch": epoch, "value": value[metric]}
              ]
  
      self.experiment_obj.save()
  
imports: import json
  from settings import settings
  from datetime import datetime
  from django.utils import timezone
  from django.contrib.auth.models import AnonymousUser
  from channels.db import database_sync_to_async
  from channels.auth import login
  from channels.generic.websocket import AsyncWebsocketConsumer
  from modelchimp.models.membership import Membership
  from modelchimp.models.experiment import Experiment
  from modelchimp.enum import ClientEvent, ExperimentStatus
label_desc: Use image node_id 4 for calling the TrackerConsumer obj's underlying member method code with example usage: obj.add_metrics(value, epoch) without return types