code: def consumer_partitions_for_topic(consumer, topic):
      
      topic_partitions = []
      partitions = consumer.partitions_for_topic(topic)
      if partitions is not None:
          for partition in partitions:
              topic_partitions.append(TopicPartition(topic, partition))
      else:
          logging.error(
              "No partitions found for topic {}. Maybe it doesn't exist?".format(topic),
          )
      return topic_partitions
docs: Returns a list of all TopicPartitions for a given topic.
  
      Arguments:
          consumer: an initialized KafkaConsumer
          topic: a topic name to fetch TopicPartitions for
  
      :returns:
          list(TopicPartition): A list of TopicPartitions that belong to the given topic