code: def test_produce_request(
      sender, mocker, api_version, produce_version
  ):
      sender.config["api_version"] = api_version
      tp = TopicPartition("foo", 0)
      buffer = io.BytesIO()
      records = MemoryRecordsBuilder(
          magic=1, compression_type=0, batch_size=100000
      )
      batch = ProducerBatch(tp, records, buffer)
      records.close()
      produce_request = sender._produce_request(0, 0, 0, [batch])
      assert isinstance(
          produce_request, ProduceRequest[produce_version]
      )
  
file_path: kafka-python/test/test_sender.py
imports: from __future__ import absolute_import
  import pytest
  import io
  from kafka.client_async import KafkaClient
  from kafka.cluster import ClusterMetadata
  from kafka.metrics import Metrics
  from kafka.protocol.produce import ProduceRequest
  from kafka.producer.record_accumulator import RecordAccumulator, ProducerBatch
  from kafka.producer.sender import Sender
  from kafka.record.memory_records import MemoryRecordsBuilder
  from kafka.structs import TopicPartition
label_desc: Use image node_id 5 for calling a global function with example usage: test_produce_request(sender, mocker, api_version, produce_version) without return types