Tell me how you would diagnose and resolve a bottleneck in a model serving pipeline.
Implement a function that analyzes stage latencies and throughput samples from a serving pipeline and returns the stage most likely causing end-to-end slowdown. If multiple stages are tied, choose the earliest stage in the pipeline.
def diagnose_bottleneck(stages, samples):
stages: list of stage names in pipeline ordersamples: list of dicts, each with stage, latency_ms, and throughput_rpsReturn the name of the bottleneck stage.
def diagnose_bottleneck(stages, samples):