def test_uses_batches_that_stepped(mock_convert):
    """Test that the LoggerConnector uses implicitly provided batches_that_stepped to log metrics."""

    trainer = MagicMock(spec=Trainer)
    trainer.fit_loop = MagicMock()
    trainer.loggers = [logger := MagicMock(spec=Logger)]
    connector = _LoggerConnector(trainer)
    mock_convert.return_value.pop.return_value = None

    connector.log_metrics(metrics := {"some_metric": 123})

    assert connector._logged_metrics == metrics
    mock_convert.assert_called_once_with(metrics)
    logger.log_metrics.assert_called_once_with(
        metrics=mock_convert.return_value, step=trainer.fit_loop.epoch_loop._batches_that_stepped
    )
    logger.save.assert_called_once_with()
    mock_convert.return_value.setdefault.assert_called_once_with("epoch", trainer.current_epoch)
Test that the LoggerConnector uses implicitly provided batches_that_stepped to log metrics.
tests/tests_pytorch/trainer/connectors/test_logger_connector.py