def METHOD_NAME(cls, variant, stocks_data, errors):
    warehouse_ids = [stock["warehouse"] for stock in stocks_data]
    cls.check_for_duplicates(warehouse_ids, errors)
    warehouses = cls.get_nodes_or_error(
        warehouse_ids, "warehouse", only_type=Warehouse
    )
    existing_stocks = variant.stocks.filter(warehouse__in=warehouses).values_list(
        "warehouse__pk", flat=True
    )
    error_msg = "Stock for this warehouse already exists for this product variant."
    indexes = []
    for warehouse_pk in existing_stocks:
        warehouse_id = graphene.Node.to_global_id("Warehouse", warehouse_pk)
        indexes.extend(
            [i for i, id in enumerate(warehouse_ids) if id == warehouse_id]
        )
    cls.update_errors(
        errors, error_msg, "warehouse", StockErrorCode.UNIQUE, indexes
    )
    return warehouses