code: def topic_offsets_for_timestamp(consumer, timestamp, topics):
      
      tp_timestamps = {}
      for topic in topics:
          topic_partitions = consumer_partitions_for_topic(consumer, topic)
          for tp in topic_partitions:
              tp_timestamps[tp] = timestamp
      return consumer.offsets_for_times(tp_timestamps)
docs: Given an initialized KafkaConsumer, timestamp, and list of topics,
      looks up the offsets for the given topics by timestamp. The returned
      offset for each partition is the earliest offset whose timestamp is greater than or
      equal to the given timestamp in the corresponding partition.
  
      Arguments:
          consumer (KafkaConsumer): an initialized kafka-python consumer
          timestamp (int): Unix epoch milliseconds. Unit should be milliseconds
              since beginning of the epoch (midnight Jan 1, 1970 (UTC))
          topics (list): List of topics whose offsets are to be fetched.
      :returns:
          ``{TopicPartition: OffsetAndTimestamp}``: mapping from partition
          to the timestamp and offset of the first message with timestamp
          greater than or equal to the target timestamp.
          Returns ``{TopicPartition: None}`` for specific topic-partiitons if:
            1. Timestamps are not supported in messages
            2. No offsets in the partition after the given timestamp
            3. No data in the topic-partition
      :raises:
          ValueError: If the target timestamp is negative
          UnsupportedVersionError: If the broker does not support looking
              up the offsets by timestamp.
          KafkaTimeoutError: If fetch failed in request_timeout_ms