code: def gen_metrics_from_log(
      csv_dict, metrics_log_file_path, raw_metrics_file_path
  ):
      if metrics_log_file_path is None or raw_metrics_file_path is None:
          return
  
      with open(metrics_log_file_path, "r") as logfile:
          lines = logfile.readlines()
  
      metrics_dict_list = []
      pattern = re.compile(" TS_METRICS | MODEL_METRICS ")
      for line in lines:
          if pattern.search(line):
              segments = line.split("|")
              name, unit, value = parse_segments_0(segments[0])
              if name is None:
                  continue
              dimensions = parse_segments_1(csv_dict, segments[1])
              timestamp = parse_segments_2(segments[2])
              metrics_dict_list.append(
                  {
                      "MetricName": "{}_{}".format(
                          csv_dict["Model"], name
                      ),
                      "Dimensions": dimensions,
                      "Unit": unit,
                      "Value": float(value),
                      "Timestamp": timestamp,
                  }
              )
  
      with open(raw_metrics_file_path, "w") as raw_file:
          json.dump(metrics_dict_list, raw_file, indent=4)
  
file_path: serve/benchmarks/utils/gen_metrics_json.py
imports: import argparse
  import csv
  import json
  import re
label_desc: Use image node_id 3 for calling a global function with example usage: gen_metrics_from_log(csv_dict, metrics_log_file_path, raw_metrics_file_path) without return types