What does this function do (how does it work)?
<pre><code>def multi_search(pat_file : open, text_file : open) -&gt; {str:[int]}:
    answer = {(p.rstrip(),re.compile(p.rstrip())):[] for p in pat_file}
    for num,line in enumerate(text_file,1):
        line = line.rstrip()
        for (p,c),lines in answer.items():
            if c.search(line) != None:
                lines.append(num)
    return {p:l for (p,c),l in answer.items()}
</code></pre>

<p><a href="https://i.stack.imgur.com/8z9wT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8z9wT.png" alt="enter image description here"></a></p>

<p>the function takes two lists, but I am not sure what the function returns, the two lists are shown in the picture.</p>

<p>Can someone explain to me that what does this function do and how does it work?</p>