class_docstr: Experiment writer for CSVLogger.
  
  Args:
      log_dir: Directory for the experiment logs
code: def _rewrite_with_new_header(self, fieldnames: List[str]) -> None:
      with self._fs.open(
          self.metrics_file_path, "r", newline=""
      ) as file:
          metrics = list(csv.DictReader(file))
  
      with self._fs.open(
          self.metrics_file_path, "w", newline=""
      ) as file:
          writer = csv.DictWriter(file, fieldnames=fieldnames)
          writer.writeheader()
          writer.writerows(metrics)
  
imports: import csv
  import logging
  import os
  from argparse import Namespace
  from typing import Any, Dict, List, Optional, Set, Union
  from torch import Tensor
  from typing_extensions import override
  from lightning.fabric.loggers.logger import Logger, rank_zero_experiment
  from lightning.fabric.utilities.cloud_io import _is_dir, get_filesystem
  from lightning.fabric.utilities.logger import _add_prefix
  from lightning.fabric.utilities.rank_zero import rank_zero_only, rank_zero_warn
  from lightning.fabric.utilities.types import _PATH
label_desc: Use image node_id 5 for calling the _ExperimentWriter obj's underlying member method code with example usage: obj._rewrite_with_new_header(fieldnames) without return types