def METHOD_NAME(
    mock_split_data,
    X_y_binary,
    AutoMLTestEnv,
    dummy_binary_pipeline,
):
    X, y = X_y_binary
    mock_split_data.return_value = split_data(
        X,
        y,
        "binary",
        test_size=0.2,
        random_seed=0,
    )
    automl_config = AutoMLConfig(
        None,
        "binary",
        LogLossBinary(),
        [],
        None,
        True,
        None,
        0,
        None,
        None,
        {},
    )
    env = AutoMLTestEnv("binary")
    with env.test_context():
        _ = train_pipeline(dummy_binary_pipeline, X, y, automl_config=automl_config)
    env.mock_fit.assert_called_once()
    env.mock_optimize_threshold.assert_not_called()
    mock_split_data.assert_not_called()
    automl_config = AutoMLConfig(
        None,
        "binary",
        LogLossBinary(),
        [],
        F1(),
        True,
        None,
        0,
        None,
        None,
        {},
    )
    with env.test_context():
        _ = train_pipeline(dummy_binary_pipeline, X, y, automl_config=automl_config)
    env.mock_fit.assert_called_once()
    env.mock_optimize_threshold.assert_called_once()
    mock_split_data.assert_called_once()