def test_tensor_to_float_conversion(tmp_path):
    """Check tensor gets converted to float."""

    class TestModel(BoringModel):
        def training_step(self, batch, batch_idx):
            self.log("a", torch.tensor(0.123), prog_bar=True, on_epoch=False)
            self.log("b", torch.tensor([1]), prog_bar=True, on_epoch=False)
            self.log("c", 2, prog_bar=True, on_epoch=False)
            return super().training_step(batch, batch_idx)

    trainer = Trainer(
        default_root_dir=tmp_path, max_epochs=1, limit_train_batches=2, logger=False, enable_checkpointing=False
    )
    trainer.fit(TestModel())

    torch.testing.assert_close(trainer.progress_bar_metrics["a"], 0.123)
    assert trainer.progress_bar_metrics["b"] == 1.0
    assert trainer.progress_bar_metrics["c"] == 2.0
    pbar = trainer.progress_bar_callback.train_progress_bar
    actual = str(pbar.postfix)
    assert actual.endswith("a=0.123, b=1.000, c=2.000"), actual
Check tensor gets converted to float.
tests/tests_pytorch/callbacks/progress/test_tqdm_progress_bar.py