def _partition_products_by_language(products):
    """ Partitions the given product models into language buckets of product id's.

        :param products: a list of product models.
        :returns: a map {language: set of product_id's}.
    """
    products_by_language = {}

    for product in products.values():
        product_id = product.get_attribute("external_product_id")
        language = product.get_attribute("language")

        if language is None:
            continue  # skip products without language

        product_set = products_by_language.get(language, set())
        product_set.add(product_id)
        products_by_language[language] = product_set

    return products_by_language