<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def decompress_file(filepath):
 """ Decompresses a file with the correct extension. Automatically detects gz, bz2 or z extension. Args: filepath (str):
 Path to file. compression (str):
 A compression mode. Valid options are "gz" or "bz2". Defaults to "gz". """

    toks = filepath.split(".")
    file_ext = toks[-1].upper()
    from monty.io import zopen
    if file_ext in ["BZ2", "GZ", "Z"]:
        with open(".".join(toks[0:-1]), 'wb') as f_out, \
                zopen(filepath, 'rb') as f_in:
            f_out.writelines(f_in)
        os.remove(filepath)