code: def check_metrics_written(wait=WAITING_TIME, max_retries=MAX_RETRIES):
      """Waits until the metrics have been written to the trial logs.
  
      Args:
          wait (numeric) : time to wait in seconds
          max_retries (int): max number of retries
      """
      i = 0
      while i < max_retries:
          all_trials = requests.get(NNI_TRIAL_JOBS_URL).json()
          if all(["finalMetricData" in trial for trial in all_trials]):
              break
          time.sleep(wait)
          i += 1
      if i == max_retries:
          raise TimeoutError("check_metrics_written() timed out")
  
file_path: recommenders/recommenders/tuning/nni/nni_utils.py
imports: import ast
  import json
  import os
  import requests
  import subprocess
  import sys
  import time
label_desc: Use image node_id 4 for calling a global function with example usage: check_metrics_written(wait, max_retries) without return types