def METHOD_NAME(tmpdir):
    """Test TPU stats are logged using a logger."""
    model = BoringModel()
    device_stats = DeviceStatsMonitor()
    trainer = Trainer(
        default_root_dir=tmpdir,
        max_epochs=2,
        limit_train_batches=5,
        accelerator="tpu",
        devices="auto",
        log_every_n_steps=1,
        callbacks=[device_stats],
        logger=AssertTpuMetricsLogger(tmpdir),
        enable_checkpointing=False,
        enable_progress_bar=False,
    )
    try:
        trainer.fit(model)
    except RuntimeError as e:
        if _using_pjrt() and "GetMemoryInfo not implemented" in str(e):
            pytest.xfail("`xm.get_memory_info` is not implemented with PJRT")
        raise e