def METHOD_NAME(environment_variables, as_option_settings=True):
    """
    Returns a pair of environment variables to add and remove from a list of
    sanitized environment variables.
    If `as_option_settings` is set to `True`, the list of environment variables
    to add is transformed into option settings in the
    'aws:elasticbeanstalk:application:environment' namespace.
    :param environment_variables: a list of the sanitized environment variables
                                  specified in the format KEY_i=VALUE_i
    :param as_option_settings: boolean indicating whether to transform
                               `environment_variables` into option settings
    :return: a pair of environment variables to add and remove in the format
             dictated by `as_option_settings`
    """
    namespace = 'aws:elasticbeanstalk:application:environment'
    options = dict()
    options_to_remove = set()
    for environment_variable_string in environment_variables:
        if (
            not re.match(r'^[\w\\_.:/+@-][^="]*=.*$', environment_variable_string)
            or '=' not in environment_variable_string
        ):
            raise InvalidSyntaxError(strings['setenv.invalidformat'])
        environment_variable, value = environment_variable_string.split('=', 1)
        if value:
            options[environment_variable] = value
        else:
            options_to_remove.add(environment_variable)
    if as_option_settings:
        option_dict = options
        options = list()
        remove_list = options_to_remove
        options_to_remove = list()
        for environment_variable, value in iteritems(option_dict):
            options.append(
                dict(
                    Namespace=namespace,
                    OptionName=environment_variable,
                    Value=value
                )
            )
        for environment_variable in remove_list:
            options_to_remove.append(
                dict(
                    Namespace=namespace,
                    OptionName=environment_variable
                )
            )
    return options, options_to_remove