To process the query, we find out its similarity with other questions, we do it by taking a dot product of training data matrix with the transpose of query data:
XX_similarity=np.dot(X_train.todense(), X_query.transpose().todense())
Now, we take out the similarity between the query and train data as a list:
XX_sim_scores= np.array(XX_similarity).flatten().tolist()