<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_swag_config_options(config):
 """Ensures that options passed to the backend are valid."""

    options = {}
    for key, val in config.items():
        if key.startswith('swag.backend.'):
            options[key[12:]] = val
        if key.startswith('swag.'):
            options[key[5:]] = val

    if options.get('type') == 's3':
        return S3OptionsSchema(strict=True).load(options).data
    elif options.get('type') == 'dynamodb':
        return DynamoDBOptionsSchema(strict=True).load(options).data
    else:
        return FileOptionsSchema(strict=True).load(options).data