<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sanitize(vpc_config):
 """ Checks that an instance of VpcConfig has the expected keys and values, removes unexpected keys, and raises ValueErrors if any expectations are violated Args: vpc_config (dict):
 a VpcConfig dict containing 'Subnets' and 'SecurityGroupIds' Returns: A valid VpcConfig dict containing only 'Subnets' and 'SecurityGroupIds' from the vpc_config parameter If vpc_config parameter is None, returns None Raises: ValueError if any expectations are violated: * vpc_config must be a non-empty dict * vpc_config must have key `Subnets` and the value must be a non-empty list * vpc_config must have key `SecurityGroupIds` and the value must be a non-empty list """

    if vpc_config is None:
        return vpc_config
    elif type(vpc_config) is not dict:
        raise ValueError('vpc_config is not a dict: {}'.format(vpc_config))
    elif not vpc_config:
        raise ValueError('vpc_config is empty')

    subnets = vpc_config.get(SUBNETS_KEY)
    if subnets is None:
        raise ValueError('vpc_config is missing key: {}'.format(SUBNETS_KEY))
    if type(subnets) is not list:
        raise ValueError('vpc_config value for {} is not a list: {}'.format(SUBNETS_KEY, subnets))
    elif not subnets:
        raise ValueError('vpc_config value for {} is empty'.format(SUBNETS_KEY))

    security_group_ids = vpc_config.get(SECURITY_GROUP_IDS_KEY)
    if security_group_ids is None:
        raise ValueError('vpc_config is missing key: {}'.format(SECURITY_GROUP_IDS_KEY))
    if type(security_group_ids) is not list:
        raise ValueError('vpc_config value for {} is not a list: {}'.format(SECURITY_GROUP_IDS_KEY, security_group_ids))
    elif not security_group_ids:
        raise ValueError('vpc_config value for {} is empty'.format(SECURITY_GROUP_IDS_KEY))

    return to_dict(subnets, security_group_ids)