code: def append_to_test_output_json(path, metrics):
      output_json = {}
      try:
          with open(path, "r") as existing_test_output_file:
              output_json = json.load(existing_test_output_file)
      except FileNotFoundError:
          pass
  
      # Set success to be previous_success && current_success.
      success = output_json.get("success", "1")
      success = (
          "1"
          if (success == "1") and (metrics["tput_images_per_s"] != -1)
          else "0"
      )
      output_json["success"] = success
  
      # Append all metrics to an array of runs.
      runs = output_json.get("runs", [])
      runs.append(metrics)
      output_json["runs"] = runs
  
      num_images_per_file = metrics["num_images_per_input_file"]
      num_files = metrics["num_files"]
      data_loader = metrics["data_loader"]
      num_cpu_nodes = metrics["num_cpu_nodes"]
  
      # Append select performance metrics to perf_metrics.
      perf_metrics = defaultdict(dict)
      perf_metrics.update(output_json.get("perf_metrics", {}))
      perf_metric_name = f"{data_loader}_{num_images_per_file}-images-per-file_{num_files}-num-files-{num_cpu_nodes}-num-cpu-nodes_throughput-img-per-second"  # noqa: E501
      # "." is not supported in metrics querying.
      perf_metric_name = perf_metric_name.replace(".", "_")
      perf_metrics[perf_metric_name].update(
          {
              "THROUGHPUT": metrics["tput_images_per_s"],
          }
      )
      output_json["perf_metrics"] = perf_metrics
  
      with open(path, "w") as test_output_file:
          json.dump(output_json, test_output_file)
  
      print(f"Finished benchmark, metrics exported to {path}.")
  
imports: from collections import defaultdict
  import tensorflow
  import numpy
  import os
  import pandas
  import time
  import logging
  import csv
  import json
  import torchvision
  import torch
  import ray
  from ray.train.tensorflow import prepare_dataset_shard, TensorflowTrainer
  from ray.train import DataConfig, ScalingConfig
  from ray import train, tune
  from ray.tune import Tuner
  from ray.data.datasource.partitioning import Partitioning
  from tf_utils import DEFAULT_IMAGE_SIZE, NUM_CHANNELS, preprocess_image, build_tf_dataset
  from metric_utils import determine_if_memory_monitor_is_enabled_in_latest_session, get_ray_spilled_and_restored_mb, MaxMemoryUtilizationTracker
label_desc: Use image node_id 11 for calling a global function with example usage: append_to_test_output_json(path, metrics) without return types