Ok. So, basically, This line is responsible for creating a cost matrix "scored_pairs" which would be given to the Hungarian Algorithm.
row_list and col_list contains the row and column indices respectively. This both list along with the scores list is given to the sparse coordinate matrix i.e coo_matrix, to build a cost matrix. Now, since we have generated the pairs of the records, a particular record may be present with many other records records and Hence their would be duplicates in the row and column list. So coo_matrix would add the scores for the duplicate indices, while dok_matrix does not tolerate duplicate indices. Hence dok_matrix is used.