code: def parse_quartus_report(hls_dir, write_to_file=True):
      """
      Parse a report from a given Quartus project as a dictionary.
  
      Args:
          hls_dir (string): The directory where the project is found
          write_to_file (bool): A flag indicating whether to write the results to a separate file
  
      Returns:
          results (dict): The report dictionary, containing latency, resource usage etc.
  
      """
      if not os.path.exists(hls_dir):
          print(f"Path {hls_dir} does not exist. Exiting.")
          return
  
      prj_dir = _find_project_dir(hls_dir)
  
      rpt_dir = hls_dir + "/" + prj_dir + "/reports"
      if not os.path.exists(rpt_dir):
          print(
              f'Project {prj_dir} does not exist. Rerun "hls4ml build -p {hls_dir}".'
          )
          return
  
      results = _find_reports(rpt_dir)
      print(results)
      if write_to_file:
          print("Here")
          f = open(hls_dir + "/" "synthesis-report.txt", "w")
          f.write("HLS Synthesis Latency & Resource Usage Report")
          for key in results:
              f.write(str(key) + ":" + str(results[key]) + "\n")
          print("There")
          print(
              f"Saved latency & resource usage summary to {hls_dir}/synthesis-report.txt"
          )
      return results
  
file_path: hls4ml/hls4ml/report/quartus_report.py
imports: import os
  import webbrowser
  from ast import literal_eval
  from calmjs.parse import asttypes, es5
  from tabulate import tabulate
label_desc: Use image node_id 1 for calling a global function with example usage: parse_quartus_report(hls_dir, write_to_file) and returns: results