<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_formula(fml_file):
 """ Parse and return MaxSAT formula. """


    if re.search('\.wcnf(\.(gz|bz2|lzma|xz))?$', fml_file):
        fml = WCNF(from_file=fml_file)
    else:  # expecting '*.cnf'
        fml = CNF(from_file=fml_file).weighted()

    return fml