def test_eegnetv4_final_layer_linear_true():
    """Test that final_layer_linear=True uses a conv-based classifier without warning."""
    model = EEGNetv4(
        final_layer_with_constraint=True,
        n_chans=4,
        n_times=128,
        n_outputs=2
    )

    X = torch.randn(2, 4, 128)  # (batch_size=2, channels=4, time=128)
    y = model(X)

    # Check output shape: should be (batch_size, n_outputs)
    assert y.shape == (2, 2), f"Unexpected output shape {y.shape}"

    # Check final layer is Conv2d instead of Flatten/LinearWithConstraint
    final_layer = dict(model.named_modules())["final_layer"]
    # Inside final_layer for conv-based approach, we expect "conv_classifier" as the first sub-module:
    assert hasattr(final_layer,
                   "linearconstraint"), "Expected a 'linear constraint' sub-module."
Test that final_layer_linear=True uses a conv-based classifier without warning.
test/unit_tests/models/test_models.py