def test_optimizer_amp_scaling_support_in_step_method():
    """Test that the plugin checks if the optimizer takes over unscaling in its step, making it incompatible with
    gradient clipping (example: fused Adam)."""

    optimizer = Mock(_step_supports_amp_scaling=True)
    precision = MixedPrecision(precision="16-mixed", device="cuda:0", scaler=Mock())

    with pytest.raises(RuntimeError, match="The current optimizer.*does not allow for gradient clipping"):
        precision.clip_gradients(optimizer, clip_val=1.0)
Test that the plugin checks if the optimizer takes over unscaling in its step, making it incompatible with
    gradient clipping (example: fused Adam).
tests/tests_pytorch/plugins/precision/test_amp.py