public static TopicMetadata fromRecord(
        ConsumerGroupPartitionMetadataValue.TopicMetadata record
    ) {
        // Converting the data type from a list stored in the record to a map for the topic metadata.
        Map<Integer, Set<String>> partitionRacks = new HashMap<>();
        for (ConsumerGroupPartitionMetadataValue.PartitionMetadata partitionMetadata : record.partitionMetadata()) {
            partitionRacks.put(
                partitionMetadata.partition(),
                Collections.unmodifiableSet(new HashSet<>(partitionMetadata.racks()))
            );
        }

        return new TopicMetadata(
            record.topicId(),
            record.topicName(),
            record.numPartitions(),
            partitionRacks);
    }
@return Every partition mapped to the set of corresponding available rack Ids of its replicas.
        An empty map is returned if rack information is unavailable for all partitions.
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/TopicMetadata.java