code: def write_metrics(
      model_metrics: dict[str, str | float],
      writers: list[str],
      folder: str | None = None,
  ):
      """Writes metrics to destination provided in the sweep config.
  
      Args:
          model_metrics (dict): Dictionary to be written
          writers (list[str]): List of destinations.
          folder (optional, str): Sub-directory to which runs are written to. Defaults to None. If none writes to root.
      """
      # Write to file as each run is computed
      if model_metrics == {} or model_metrics is None:
          return
  
      # Write to CSV
      metrics_df = pd.DataFrame(model_metrics, index=[0])
      result_folder = (
          Path("runs") if folder is None else Path(f"runs/{folder}")
      )
      result_path = (
          result_folder
          / f"{model_metrics['model_name']}_{model_metrics['device']}.csv"
      )
      Path.mkdir(result_path.parent, parents=True, exist_ok=True)
      if not result_path.is_file():
          metrics_df.to_csv(result_path)
      else:
          metrics_df.to_csv(result_path, mode="a", header=False)
  
      if "tensorboard" in writers:
          write_to_tensorboard(model_metrics)
  
file_path: anomalib/tools/benchmarking/utils/metrics.py
imports: from __future__ import annotations
  import random
  import string
  from glob import glob
  from pathlib import Path
  import pandas
  import wandb
  from comet_ml import Experiment
  from torch.utils.tensorboard.writer import SummaryWriter
label_desc: Use image node_id 1 for calling a global function with example usage: write_metrics(model_metrics, writers, folder) without return types