def METHOD_NAME(f, name=None):
    fn = types.FunctionType(f.__code__, f.__globals__, name if name else f.__name__,
                            f.__defaults__, f.__closure__)
    fn.__dict__.update(copy.deepcopy(f.__dict__))
    return fn