code: def test_append_metrics_file(tmp_path):
      """Test that the logger appends to the file instead of rewriting it on every save."""
      logger = CSVLogger(
          tmp_path, name="test", version=0, flush_logs_every_n_steps=1
      )
  
      # initial metrics
      logger.log_metrics({"a": 1, "b": 2})
      logger.log_metrics({"a": 3, "b": 4})
  
      # create a new logger to show we append to the existing file
      logger = CSVLogger(
          tmp_path, name="test", version=0, flush_logs_every_n_steps=1
      )
      logger.log_metrics({"a": 100, "b": 200})
  
      with open(logger.experiment.metrics_file_path) as file:
          lines = file.readlines()
      assert len(lines) == 4
  
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 11 for calling a global function with example usage: test_append_metrics_file(tmp_path) without return types