code: def test_write_read_metric_file():
      expected_metrics = [
          {"float_metric": 3.45, "bool_metric": True},
          {"float_metric": 1.0, "bool_metric": False},
      ]
      with TemporaryDirectory(prefix="metric_file") as work_dir:
          metric_path = os.path.join(work_dir, "metrics")
          utils.write_metrics_file(expected_metrics, metric_path)
          read_metrics = utils.read_metrics_file(metric_path)
  
      assert len(read_metrics) == len(expected_metrics)
      assert expected_metrics == read_metrics
  
imports: import gzip
  import math
  import os
  import re
  from tempfile import TemporaryDirectory
  import unittest
  import numpy
  import pytest
  import torch
  from sockeye import __version__
  from sockeye import constants
  from sockeye import utils
label_desc: Use image node_id 20 for calling a global function with example usage: test_write_read_metric_file() without return types