def test_pytorch_profiler_multiple_loggers(tmp_path):
    """Tests whether the PyTorch profiler is able to write its trace locally when the Trainer is configured with
    multiple loggers.

    See issue #8157.

    """

    def look_for_trace(trace_dir):
        """Determines if a directory contains a PyTorch trace."""
        return any("trace.json" in filename for filename in os.listdir(trace_dir))

    model = BoringModel()
    loggers = [TensorBoardLogger(save_dir=tmp_path), CSVLogger(tmp_path)]
    trainer = Trainer(
        default_root_dir=tmp_path, profiler="pytorch", logger=loggers, limit_train_batches=5, max_epochs=1
    )
    assert len(trainer.loggers) == 2
    trainer.fit(model)
    assert look_for_trace(tmp_path / "lightning_logs" / "version_0")
Tests whether the PyTorch profiler is able to write its trace locally when the Trainer is configured with
    multiple loggers.

    See issue #8157.

    
tests/tests_pytorch/profilers/test_profiler.py