code: def encode_fetch_request(cls, client_id, correlation_id, payloads=None,
                               max_wait_time=100, min_bytes=4096):
          
          payloads = [] if payloads is None else payloads
          grouped_payloads = group_by_topic_and_partition(payloads)
  
          message = cls._encode_message_header(client_id, correlation_id,
                                               KafkaCodec.FETCH_KEY)
  
          assert isinstance(max_wait_time, int)
  
          # -1 is the replica id
          message += struct.pack('>iiii', -1, max_wait_time, min_bytes,
                                 len(grouped_payloads))
  
          for topic, topic_payloads in grouped_payloads.items():
              message += write_short_ascii(topic)
              message += struct.pack('>i', len(topic_payloads))
              for partition, payload in topic_payloads.items():
                  message += struct.pack('>iqi', partition, payload.offset,
                                         payload.max_bytes)
  
          return message
docs: Encodes some FetchRequest structs
  
          :param bytes client_id:
          :param int correlation_id:
          :param list payloads: list of :class:`FetchRequest`
          :param int max_wait_time: how long to block waiting on min_bytes of data
          :param int min_bytes:
              the minimum number of bytes to accumulate before returning the
              response