def test_uses_provided_step(mock_convert):
    """Test that the LoggerConnector uses explicitly provided step to log metrics."""

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

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

    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=step)
    logger.save.assert_called_once_with()
Test that the LoggerConnector uses explicitly provided step to log metrics.
tests/tests_pytorch/trainer/connectors/test_logger_connector.py