<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _set(name, value, function=None):
 """Internally set a config parameter. If you call it with no function, it sets the global parameter. If you call it with a function argument, it sets the value for the specified function. Normally, this should only be called with a function argument for internal code. This should not be called by code outside of the paranoid module. """


        if name not in Settings.__global_setting_values.keys():
            raise NameError("Invalid setting value")
        if name in Settings.__validate_settings.keys():
            if not Settings.__validate_settings[name](value):
                raise ValueError("Invalid setting: %s = %s" %
                                 (name, value))
        # Set the setting either globally (if no function is passed)
        # or else locally to the function (if a function is passed).
        if function:
            if not hasattr(function, Settings.FUNCTION_SETTINGS_NAME):
                setattr(function, Settings.FUNCTION_SETTINGS_NAME, {})
                # Test if this wraps something.  TODO this will fail
                # for nested decorators.  This also assumes that, if
                # there is a wrapped function (super wraps sub), that
                # if super doesn't have settings, then sup doesn't
                # either.  (This assumption is valid for paranoid
                # decorators since it properly uses update_wrapper,
                # but may not be valid for other decorators.)
                if hasattr(function, "__wrapped__"):
                    setattr(function.__wrapped__,
                            Settings.FUNCTION_SETTINGS_NAME,
                            getattr(function, Settings.FUNCTION_SETTINGS_NAME))
            getattr(function, Settings.FUNCTION_SETTINGS_NAME)[name] = value
        else:
            Settings.__global_setting_values[name] = value