Query-Dependent Prompt Evaluation and Optimization with Offline Inverse RL