[2407.09297] Learning Distances from Data with Normalizing Flows and Score Matching