code: def _build_record_batch(msgs, compression=0):
      builder = MemoryRecordsBuilder(
          magic=1, compression_type=0, batch_size=9999999
      )
      for msg in msgs:
          key, value, timestamp = msg
          builder.append(
              key=key, value=value, timestamp=timestamp, headers=[]
          )
      builder.close()
      return builder.buffer()
  
imports: from __future__ import absolute_import
  import pytest
  from collections import OrderedDict
  import itertools
  import time
  from kafka.client_async import KafkaClient
  from kafka.consumer.fetcher import CompletedFetch, ConsumerRecord, Fetcher, NoOffsetForPartitionError
  from kafka.consumer.subscription_state import SubscriptionState
  from kafka.future import Future
  from kafka.metrics import Metrics
  from kafka.protocol.fetch import FetchRequest, FetchResponse
  from kafka.protocol.offset import OffsetResponse
  from kafka.errors import StaleMetadata, LeaderNotAvailableError, NotLeaderForPartitionError, UnknownTopicOrPartitionError, OffsetOutOfRangeError
  from kafka.record.memory_records import MemoryRecordsBuilder, MemoryRecords
  from kafka.structs import OffsetAndMetadata, TopicPartition
label_desc: Use image node_id 5 for calling a global function with example usage: _build_record_batch(msgs, compression) and returns: builder