def extract(line, extract_expr):
    """
    return the extracted information list, such as losses.
    """
    log("Extract_expression is : ", extract_expr)
    x = re.findall("\{%(.)\}", extract_expr)
    assert len(x) == 1, "Must exist a {%d} | {%f} | {%s} "
    t = x[0]
    type_converter = {
        'f': float,
        'i': int,
        's': str,
    }
    type_extracter = {
        "f": r'(-?\\d+\\.\\d+)',
        "i": r'(-?\\d+)',
        "s": r'(.*?)',
    }
    log(type_extracter[t])
    pattern = re.sub("\{%(.)\}", type_extracter[t], extract_expr, 1)
    log("Created Pattern is: ", pattern)
    x = re.findall(pattern, line)
    if len(x) == 0: return None
    assert len(
        x
    ) == 1, f"Multiply matches are found for `{extract_expr}` in line: \n{line}"
    log("Find in line: ", x[0].strip())
    return type_converter[t](x[0].strip())

    return the extracted information list, such as losses.
    
test_tipc/extract_loss.py