Sort each sample of the data set A in a two-dimensional space according to a certain rule, that is, make it representable in two-dimensional coordinates. (According to the degree of similarity, correlation, etc. between the samples)

When a sample is extracted from the data set B and input to the deep learning model, the model can search in the data set A to obtain a sample (set) that has a certain correlation with the input sample.

Not related to deeplearning but you can take a look at metric-learning http://contrib.scikit-learn.org/metric-learn/introduction.html . This kind of machine learning technique will try to reduce the distance of 2 similar samples and increase distance for different samples