human
Complete the below
def addtoapi(*dargs, **dkwargs):

    ''''Helper decorator that adds function to the API class.
    is used to reuse as much code as possible
    args:
    dargs: (string, optional) Used to rename a function
    Example:
    @addtoapi("i_was_renamed", "im_a_second_alias")
    @addtoapi()'
    '''
 Write me a the Python code you requested?
assistant
#Here is the Python code you requested.
    def rd(function):
        @wraps(function)
        def wrapper(*args, **kwargs):
            return function(*args, **kwargs)
        if dargs:
            for n in dargs:
                if (function.__doc__ and len(function.__doc__)):
                    function.__doc__ = function.__doc__.strip()
                setattr(API2, n, function)
            return wrapper
        if (function.__doc__ and len(function.__doc__)):
            function.__doc__ = function.__doc__.strip()
        setattr(API2, function.__name__, function)
        return wrapper
    return rd