def METHOD_NAME(
    checkout_info: "CheckoutInfo",
    lines: Iterable["CheckoutLineInfo"],
    variant_stock_map: dict[
        tuple[
            VARIANT_ID,
            CHANNEL_SLUG,
            COUNTRY_CODE,
        ],
        Iterable[Stock],
    ],
    product_channel_listings_map: dict[
        tuple[
            PRODUCT_ID,
            CHANNEL_SLUG,
        ],
        ProductChannelListing,
    ],
) -> dict[CHECKOUT_LINE_PK_TYPE, list[CHECKOUT_LINE_PROBLEM_TYPE]]:
    """Return a list of all problems with the checkout lines.
    The stocks need to have annotated available_quantity field.
    """
    problems: dict[
        CHECKOUT_LINE_PK_TYPE, list[CHECKOUT_LINE_PROBLEM_TYPE]
    ] = defaultdict(list)
    not_available_lines = get_not_available_lines(lines, product_channel_listings_map)
    if not_available_lines:
        for line in not_available_lines:
            problems[str(line.line.pk)].append(
                CheckoutLineProblemVariantNotAvailable(line=line.line)
            )
    lines = [line for line in lines if line not in not_available_lines]
    insufficient_stock = get_insufficient_stock_lines(
        lines, variant_stock_map, checkout_info.checkout.country.code
    )
    if insufficient_stock:
        for line_info, available_quantity in insufficient_stock:
            problems[str(line_info.line.pk)].append(
                CheckoutLineProblemInsufficientStock(
                    available_quantity=max(available_quantity, 0),
                    line=line_info.line,
                    variant=ChannelContext(
                        node=line_info.variant, channel_slug=line_info.channel.slug
                    ),
                )
            )
    return problems