def convert_and_verify(
    pytorch_model,
    input_data,
    input_as_shape=False,
    pass_pipeline=None,
    minimum_deployment_target=ct.target.iOS18,
    expected_ops=None,
):
    """
    Utility to:
    1) Convert a PyTorch model to coreml format
    2) Compare their outputs for numerical equivalence
    3) Verify the converted model contains expected ops

    Args:
        input_as_shape: If true generates random input data with shape.
        expected_ops: List of MIL ops expected in the converted model
    Returns:
        Converted coreml model
    """
    if input_as_shape:
        example_input = torch.rand(input_data)
    else:
        example_input = input_data

    # Generate converted model
    coreml_model = get_converted_model(
        pytorch_model, example_input, pass_pipeline, minimum_deployment_target
    )
    assert coreml_model is not None

    # Verify converted model output matches torch model
    verify_model_outputs(pytorch_model, coreml_model, example_input)

    # Verify desired ops are present
    verify_ops(coreml_model, expected_ops)

    return coreml_model

    Utility to:
    1) Convert a PyTorch model to coreml format
    2) Compare their outputs for numerical equivalence
    3) Verify the converted model contains expected ops

    Args:
        input_as_shape: If true generates random input data with shape.
        expected_ops: List of MIL ops expected in the converted model
    Returns:
        Converted coreml model
    
coremltools/test/optimize/torch/conversion/conversion_utils.py