UKPLab/util.py has a paragraph_mining function. It's nice in that it does it over batches, rather than loading all at once, which will be needed eventually for larger x<->y comparisons. I didn't do it yet myself since it uses top-k, and I want all - I don't know if k can just be set to 1 or 0 or len(corpus) to bypass.