Learning Distance Metrics with Contextual Constraints for Image Retrieval | Synapse