import inspect
import warnings


def get_signature_start(function, clean_module_name):
    """For the Dense layer, it should return the string 'keras.layers.Dense'"""
    try:
        function_module = function.__module__
    except AttributeError:
        warnings.warn(f'function {function} has no module. '
                      f'It will not be included in the signature.')
        function_module = ''
    else:
        function_module = f'{clean_module_name(function_module)}.'
    return f'{function_module}{function.__name__}'


def get_function_signature(
    function, clean_module_name, post_process_signature, method=True
):
    original_function = getattr(function, "_original_function", function)
    signature = inspect.getfullargspec(original_function)
    if method:
        args = signature.args[1:]
    else:
        args = signature.args
    defaults = signature.defaults
    if defaults:
        kwargs = zip(args[-len(defaults):], defaults)
        args = args[: -len(defaults)]
    else:
        kwargs = []

    signature_start = get_signature_start(function, clean_module_name)
    st = f'{signature_start}('

    for a in args:
        st += str(a) + ", "
    for a, v in kwargs:
        if isinstance(v, str):
            v = f"'{v}'"
        st += f'{a}={v}, '
    if kwargs or args:
        signature = st[:-2] + ")"
    else:
        signature = st + ")"
    return post_process_signature(signature)


def get_class_signature(cls, clean_module_name, post_process_signature):
    try:
        init_method = cls.__init__
    except (TypeError, AttributeError):
        # in case the class inherits from object and does not
        # define __init__
        class_signature = f"{cls.__module__}.{cls.__name__}()"
    else:
        class_signature = get_function_signature(
            init_method, clean_module_name, post_process_signature
        )
        class_signature = class_signature.replace("__init__", cls.__name__)
    return post_process_signature(class_signature)

@@ -530,16 +530,333 @@
 e__%7D'%0A%0A%0A
+def get_signature_end(args, kwargs):%0A    kwargs_formatted = %5B%5D%0A    for a, v in kwargs:%0A        if isinstance(v, str):%0A            v = f%22'%7Bv%7D'%22%0A        kwargs_formatted.append(f'%7Ba%7D=%7Bv%7D')%0A%0A    all_args_str = map(str, args + kwargs_formatted)%0A    all_args_str = ', '.join(all_args_str)%0A    return f'(%7Ball_args_str%7D)'%0A%0A%0A
 def get_
@@ -1421,16 +1421,8 @@
     
-st = f'%7B
 sign
@@ -1431,267 +1431,45 @@
 ure_
-start%7D('%0A%0A    for a in args:%0A        st += str(a) + %22, %22%0A    for a, v in kwargs:%0A        if isinstance(v, str):%0A            v = f%22'%7Bv%7D'%22%0A        st += f'%7Ba%7D=%7Bv%7D, '%0A    if kwargs or args:%0A        signature = st%5B:-2%5D + %22)%22%0A    else:%0A        signature = st + %22)%22
+end = get_signature_end(args, kwargs)
 %0A   
@@ -1508,16 +1508,38 @@
 ignature
+_start + signature_end
 )%0A%0A%0Adef 

Simplified the making of the args as strings. (#8)