def test_custom_pipeline(pair_classification_pipeline: PairClassificationPipeline):
    """
    Test saving and loading a custom pipeline from scratch. This is not covered by the framework tests
    because it does not load a custom pipeline without first adding to the transformers SUPPORTED_TASKS.
    """
    from bentoml._internal.frameworks.transformers import PIPELINE_PICKLE_NAME

    from .models.transformers import PairClassificationPipeline

    bento_model = bentoml.transformers.save_model(
        "my_classification_model",
        pipeline=pair_classification_pipeline,
        task_name=TASK_NAME,
        task_definition={
            "impl": PairClassificationPipeline,
            "pt": AutoModelForSequenceClassification,
        },
    )

    assert os.path.exists(bento_model.path_of(PIPELINE_PICKLE_NAME))
    assert bento_model.tag.name == "my_classification_model"

    loaded_pipeline = bentoml.transformers.load_model("my_classification_model:latest")
    assert pair_classification_pipeline(
        "I hate you", second_text="I love you"
    ) == loaded_pipeline("I hate you", second_text="I love you")

    # Test runners
    bento_model = bentoml.transformers.get("my_classification_model")
    runner = bento_model.to_runner()
    runner.init_local()

    assert runner.run(
        "I hate you", second_text="I love you"
    ) == pair_classification_pipeline("I hate you", second_text="I love you")

    runner.destroy()

    runner = bento_model.to_runner()
    runner.init_local()
    assert runner.run(
        "I hate you", second_text="I love you"
    ) == pair_classification_pipeline("I hate you", second_text="I love you")

    runner.destroy()
Test saving and loading a custom pipeline from scratch. This is not covered by the framework tests
because it does not load a custom pipeline without first adding to the transformers SUPPORTED_TASKS.
tests/integration/frameworks/test_transformers_unit.py