def METHOD_NAME(
    category_taxonomy: Taxonomy,
    ingredient_taxonomy: Taxonomy,
    stream: ProductStream,
    lang: Optional[str],
) -> Iterator[JSONType]:
    for product in stream.iter():
        categories_tags: list[str] = product["categories_tags"]
        inferred_categories_tags: list[TaxonomyNode] = list(
            infer_category_tags(categories_tags, category_taxonomy)
        )
        if inferred_categories_tags:
            ingredient_tags = product.get("ingredients_tags", [])
            ingredient_tags = [x for x in ingredient_tags if x]
            known_ingredient_tags = [
                ingredient_tag
                for ingredient_tag in ingredient_tags
                if ingredient_tag in ingredient_taxonomy
            ]
            ingredients_text_field = (
                "ingredients_text_{}".format(lang) if lang else "ingredients_text"
            )
            ingredients_text = product.get(ingredients_text_field, None) or None
            product_name_field = (
                "product_name_{}".format(lang) if lang else "product_name"
            )
            yield {
                "code": product["code"],
                "nutriments": product.get("nutriments") or None,
                "images": product.get("images", {}) or None,
                "product_name": product[product_name_field],
                "categories_tags": [x.id for x in inferred_categories_tags],
                "ingredient_tags": ingredient_tags,
                "known_ingredient_tags": known_ingredient_tags,
                "ingredients_text": ingredients_text,
                "lang": product.get("lang", None),
            }