def test_log_tensor_and_clone_no_torch_warning(tmp_path):
    """Regression test for issue https://github.com/Lightning-AI/pytorch-lightning/issues/14594."""

    class TestModel(BoringModel):
        def training_step(self, *args):
            self.log("foo", torch.tensor(1))
            return super().training_step(*args)

    trainer = Trainer(default_root_dir=tmp_path, fast_dev_run=1)
    model = TestModel()
    match = r"recommended.*.clone\(\).detach\(\)"
    with no_warning_call(UserWarning, match=match):
        trainer.fit(model)
Regression test for issue https://github.com/Lightning-AI/pytorch-lightning/issues/14594.
tests/tests_pytorch/trainer/logging_/test_train_loop_logging.py