code: def test_rewrite_with_new_header(tmp_path):
      # write a csv file manually
      with open(tmp_path / "metrics.csv", "w") as file:
          file.write("step,metric1,metric2\n")
          file.write("0,1,22\n")
  
      writer = _ExperimentWriter(log_dir=str(tmp_path))
      new_columns = ["step", "metric1", "metric2", "metric3"]
      writer._rewrite_with_new_header(new_columns)
  
      # the rewritten file should have the new columns
      with open(tmp_path / "metrics.csv") as file:
          header = file.readline().strip().split(",")
          assert header == new_columns
          logs = file.readline().strip().split(",")
          assert logs == ["0", "1", "22", ""]
  
file_path: pytorch-lightning/tests/tests_fabric/loggers/test_csv.py
imports: import os
  from unittest.mock import MagicMock
  import pytest
  import torch
  from lightning.fabric.loggers import CSVLogger
  from lightning.fabric.loggers.csv_logs import _ExperimentWriter
label_desc: Use image node_id 13 for calling a global function with example usage: test_rewrite_with_new_header(tmp_path) without return types