@classmethod<EOL><INDENT>def encode_offset_fetch_request(cls, client_id, correlation_id,<EOL>group, payloads, from_kafka=False):<DEDENT>
grouped_payloads = group_by_topic_and_partition(payloads)<EOL>message = []<EOL>reqver = <NUM_LIT:1> if from_kafka else <NUM_LIT:0><EOL>message.append(cls._encode_message_header(client_id, correlation_id,<EOL>KafkaProtocol.OFFSET_FETCH_KEY,<EOL>version=reqver))<EOL>message.append(write_short_string(group))<EOL>message.append(struct.pack('<STR_LIT>', len(grouped_payloads)))<EOL>for topic, topic_payloads in grouped_payloads.items():<EOL><INDENT>message.append(write_short_string(topic))<EOL>message.append(struct.pack('<STR_LIT>', len(topic_payloads)))<EOL>for partition, payload in topic_payloads.items():<EOL><INDENT>message.append(struct.pack('<STR_LIT>', partition))<EOL><DEDENT><DEDENT>msg = b'<STR_LIT>'.join(message)<EOL>return struct.pack('<STR_LIT>' % len(msg), len(msg), msg)<EOL>
Encode some OffsetFetchRequest structs. The request is encoded using
version 0 if from_kafka is false, indicating a request for Zookeeper
offsets. It is encoded using version 1 otherwise, indicating a request
for Kafka offsets.

Arguments:
    client_id: string
    correlation_id: int
    group: string, the consumer group you are fetching offsets for
    payloads: list of OffsetFetchRequest
    from_kafka: bool, default False, set True for Kafka-committed offsets