def get_converted_model(
    pytorch_model,
    input_data,
    pass_pipeline=None,
    minimum_deployment_target=ct.target.iOS17,
):
    """
    Utility that takes a PyTorch model and converts it to a coreml model
    """
    traced_model = torch.jit.trace(pytorch_model, example_inputs=(input_data,))
    coreml_model = None
    try:
        coreml_model = ct.convert(
            traced_model,
            inputs=[ct.TensorType(shape=input_data.shape)],
            pass_pipeline=pass_pipeline,
            minimum_deployment_target=minimum_deployment_target,
        )
    except Exception as err:
        print(f"Conversion Error: {err}")

    return coreml_model

    Utility that takes a PyTorch model and converts it to a coreml model
    
coremltools/test/optimize/torch/conversion/conversion_utils.py