A new function to average a similarity matrix based on a partition.