Learning to Weight Imperfect Demonstrations