<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def on_delivery_confirmation(self, method_frame):
 """Invoked by pika when RabbitMQ responds to a Basic.Publish RPC command, passing in either a Basic.Ack or Basic.Nack frame with the delivery tag of the message that was published. The delivery tag is an integer counter indicating the message number that was sent on the channel via Basic.Publish. Here we're just doing house keeping to keep track of stats and remove message numbers that we expect a delivery confirmation of from the list used to keep track of messages that are pending confirmation. :param pika.frame.Method method_frame: Basic.Ack or Basic.Nack frame """

        confirmation_type = method_frame.method.NAME.split('.')[1].lower()
        LOGGER.debug('Received %s for delivery tag: %i',
                     confirmation_type, method_frame.method.delivery_tag)

        if method_frame.method.multiple:
            confirmed = sorted([msg for msg in self.messages
                                if msg <= method_frame.method.delivery_tag])
        else:
            confirmed = [method_frame.method.delivery_tag]

        for msg in confirmed:
            LOGGER.debug('RabbitMQ confirmed message %i', msg)
            try:
                if confirmation_type == 'ack':
                    self.messages[msg].set_result(None)
                elif confirmation_type == 'nack':
                    self.messages[msg].set_exception(PublishingFailure(msg))
            except KeyError:
                LOGGER.warning('Tried to confirm a message missing in stack')
            else:
                del self.messages[msg]

        LOGGER.debug('Published %i messages, %i have yet to be confirmed',
                     self.message_number, len(self.messages))