public static Map<Uuid, Set<Integer>> toTopicPartitionMap(
        ConsumerProtocolAssignment consumerProtocolAssignment,
        TopicsImage topicsImage
    ) {
        Map<Uuid, Set<Integer>> topicPartitionMap = new HashMap<>();
        consumerProtocolAssignment.assignedPartitions().forEach(topicPartition -> {
            TopicImage topicImage = topicsImage.getTopic(topicPartition.topic());
            if (topicImage != null) {
                topicPartitionMap.put(topicImage.id(), new HashSet<>(topicPartition.partitions()));
            }
        });
        return topicPartitionMap;
    }
Converts a map of topic id and partition set to a ConsumerProtocolAssignment.

@param consumerProtocolAssignment    The ConsumerProtocolAssignment.
@param topicsImage                   The TopicsImage.
@return The converted map.
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/Utils.java