code: def restore_offsets(cls, client, parsed_consumer_offsets):
          
          # Fetch current offsets
          try:
              consumer_group = parsed_consumer_offsets['groupid']
              topics_offset_data = parsed_consumer_offsets['offsets']
              topic_partitions = dict(
                  (topic, [partition for partition in offset_data.keys()])
                  for topic, offset_data in six.iteritems(topics_offset_data)
              )
          except IndexError:
              print(
                  "Error: Given parsed consumer-offset data {consumer_offsets} "
                  "could not be parsed".format(consumer_offsets=parsed_consumer_offsets),
                  file=sys.stderr,
              )
              raise
          current_offsets = get_consumer_offsets_metadata(
              client,
              consumer_group,
              topic_partitions,
          )
          # Build new offsets
          new_offsets = cls.build_new_offsets(
              client,
              topics_offset_data,
              topic_partitions,
              current_offsets,
          )
  
          # Commit offsets
          consumer_group = parsed_consumer_offsets['groupid']
          set_consumer_offsets(client, consumer_group, new_offsets)
          print("Restored to new offsets {offsets}".format(offsets=dict(new_offsets)))
docs: Fetch current offsets from kafka, validate them against given
          consumer-offsets data and commit the new offsets.
  
          :param client: Kafka-client
          :param parsed_consumer_offsets: Parsed consumer offset data from json file
          :type parsed_consumer_offsets: dict(group: dict(topic: partition-offsets))