IPA: Inference Pipeline Adaptation to Achieve High Accuracy and Cost-Efficiency