code: def test_partition_records_compacted_offset():
      """Test that messagesets are handle correctly
      when the fetch offset points to a message that has been compacted
      """
      batch_start = 0
      batch_end = 100
      fetch_offset = 42
      tp = TopicPartition("foo", 0)
      messages = [
          ConsumerRecord(
              tp.topic,
              tp.partition,
              i,
              None,
              None,
              "key",
              "value",
              None,
              "checksum",
              0,
              0,
              -1,
          )
          for i in range(batch_start, batch_end)
          if i != fetch_offset
      ]
      records = Fetcher.PartitionRecords(fetch_offset, None, messages)
      assert len(records) == batch_end - fetch_offset - 1
      msgs = records.take(1)
      assert msgs[0].offset == fetch_offset + 1
  
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 26 for calling a global function with example usage: test_partition_records_compacted_offset() without return types