public Map<TopicIdPartition, Acknowledgements> takeAcknowledgedRecords() {
        Map<TopicIdPartition, Acknowledgements> acknowledgementMap = new LinkedHashMap<>();
        batches.forEach((tip, batch) -> {
            Acknowledgements acknowledgements = batch.takeAcknowledgedRecords();
            if (!acknowledgements.isEmpty())
                acknowledgementMap.put(tip, acknowledgements);
        });
        return acknowledgementMap;
    }
Removes all acknowledged records from the in-flight records and returns the map of acknowledgements
to send. If some records were not acknowledged, the in-flight records will not be empty after this
method.

@return The map of acknowledgements to send
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareFetch.java