code: def test_append_columns(tmp_path):
      """Test that the CSV file gets rewritten with new headers if the columns change."""
      logger = CSVLogger(tmp_path, flush_logs_every_n_steps=1)
  
      # initial metrics
      logger.log_metrics({"a": 1, "b": 2})
  
      # new key appears
      logger.log_metrics({"a": 1, "b": 2, "c": 3})
      with open(logger.experiment.metrics_file_path) as file:
          header = file.readline().strip()
          assert set(header.split(",")) == {"step", "a", "b", "c"}
  
      # key disappears
      logger.log_metrics({"a": 1, "c": 3})
      with open(logger.experiment.metrics_file_path) as file:
          header = file.readline().strip()
          assert set(header.split(",")) == {"step", "a", "b", "c"}
  
imports: import os
  from unittest.mock import MagicMock
  import fsspec
  import pytest
  import torch
  from lightning.pytorch import Trainer
  from lightning.pytorch.core.saving import load_hparams_from_yaml
  from lightning.pytorch.loggers import CSVLogger
  from lightning.pytorch.loggers.csv_logs import ExperimentWriter
  from tests_pytorch.helpers.datamodules import ClassifDataModule
  from tests_pytorch.helpers.runif import RunIf
  from tests_pytorch.helpers.simple_models import ClassificationModel
label_desc: Use image node_id 12 for calling a global function with example usage: test_append_columns(tmp_path) without return types