human
What is a the Python code you requested given the following:
Complete the below
def def_to_cdef(source):

    ''''Converts the module-level def methods into cdef methods, i.e.
    @decorator
    def foo([args]):
    [tests]
    [body]
    becomes
    def foo([args]):
    [tests]
    return foo_c([args])
    cdef foo_c([args]):
    [body]'
    '''
assistant
#Here is the Python code you requested.
    output = []
    skip = False
    def_node = re.compile('def    (\\w+)\\(([^()*]*)\\):').match
    lines = iter(source.split('\n'))
    for line in lines:
        if (not line.strip()):
            output.append(line)
            continue
        if skip:
            if (line[0] != '    '):
                skip = False
            else:
                continue
        if (line[0] == '@'):
            skip = True
            continue
        m = def_node(line)
        if m:
            name = m.group(1)
            args = m.group(2)
            if args:
                args_no_types = ',    '.join((arg.split()[(-1)] for arg in args.split(',')))
            else:
                args_no_types = ''
            output.append(('def    %s(%s):' % (name, args_no_types)))
            line = next(lines)
            if ('"""' in line):
                has_docstring = True
                output.append(line)
                for line in lines:
                    output.append(line)
                    if ('"""' in line):
                        break
            else:
                has_docstring = False
            output.append(('                return    %s_c(%s)' % (name, args_no_types)))
            output.append('')
            output.append(('cdef    %s_c(%s):' % (name, args)))
            if (not has_docstring):
                output.append(line)
        else:
            output.append(line)
    return '\n'.join(output)