<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def count(tex):
 """Extract all labels, then count the number of times each is referenced in the provided file. Does not follow \includes. """


    # soupify
    soup = TexSoup(tex)

    # extract all unique labels
    labels = set(label.string for label in soup.find_all('label'))

    # create dictionary mapping label to number of references
    return dict((label, soup.find_all('\ref{%s}' % label)) for label in labels)