code: def save_prometheus_metrics(
      start_time: float,
      end_time: Optional[float] = None,
      path: Optional[str] = None,
      use_ray: bool = False,
  ) -> bool:
      path = path or os.environ.get("METRICS_OUTPUT_JSON", None)
      if path:
          if not end_time:
              end_time = time.time()
          if use_ray:
              import ray
              from ray.air.util.node import _force_on_current_node
  
              addr = os.environ.get("RAY_ADDRESS", None)
              ray.init(addr)
  
              @ray.remote(num_cpus=0)
              def get_metrics():
                  end_time = time.time()
                  return get_prometheus_metrics(start_time, end_time)
  
              remote_run = _force_on_current_node(get_metrics)
              ref = remote_run.remote()
              metrics = ray.get(ref, timeout=900)
          else:
              metrics = get_prometheus_metrics(start_time, end_time)
          with open(path, "w") as metrics_output_file:
              json.dump(metrics, metrics_output_file)
          return path
      return None
  
file_path: ray/release/ray_release/command_runner/_prometheus_metrics.py
imports: import asyncio
  import aiohttp
  import os
  import time
  import traceback
  from urllib.parse import quote
  from typing import Optional
  import logging
  import json
  import argparse
label_desc: Use image node_id 2 for calling a global function with example usage: save_prometheus_metrics(start_time, end_time, path, use_ray) and returns: None, path, get_prometheus_metrics