docs: def encode_produce_request(cls, client_id, correlation_id,
                                 payloads=None, acks=1, timeout=1000):
          """
          Encode some ProduceRequest structs
  
          Arguments:
              client_id: string
              correlation_id: int
              payloads: list of ProduceRequest
              acks: How "acky" you want the request to be
                  0: immediate response
                  1: written to disk by the leader
                  2+: waits for this many number of replicas to sync
                  -1: waits for all replicas to be in sync
              timeout: Maximum time the server will wait for acks from replicas.
                  This is _not_ a socket timeout
  
          """
          payloads = [] if payloads is None else payloads
          grouped_payloads = group_by_topic_and_partition(payloads)
  
          message = []
          message.append(cls._encode_message_header(client_id, correlation_id,
                                                    KafkaProtocol.PRODUCE_KEY))
  
          message.append(struct.pack('>hii', acks, timeout,
                                     len(grouped_payloads)))
  
          for topic, topic_payloads in grouped_payloads.items():
              message.append(struct.pack('>h%dsi' % len(topic), len(topic), topic,
                                         len(topic_payloads)))
  
              for partition, payload in topic_payloads.items():
                  msg_set = KafkaProtocol._encode_message_set(payload.messages)
                  message.append(struct.pack('>ii%ds' % len(msg_set), partition,
                                             len(msg_set), msg_set))
  
          msg = b''.join(message)
          return struct.pack('>i%ds' % len(msg), len(msg), msg)