<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def remove_range_by_score(self, minval, maxval, include_min=True,
                              include_max=True, callback=None):
        '''Remove a range with scores between ``minval`` and ``maxval``.

        :param minval: the start value of the range to remove
        :param maxval: the end value of the range to remove
        :param include_min: whether or not to include ``minval`` in the
            values to remove
        :param include_max: whether or not to include ``maxval`` in the
            scores to to remove
        :param callback: optional callback function invoked for each
            score, value pair removed.
        :return: the number of elements removed.
        '''
        node = self._head
        chain = [None] * self._level
        if include_min:
            for i in range(self._level-1, -1, -1):
                while node.next[i] and node.next[i].score < minval:
                    node = node.next[i]
                chain[i] = node
        else:
            for i in range(self._level-1, -1, -1):
                while node.next[i] and node.next[i].score <= minval:
                    node = node.next[i]
                chain[i] = node
        node = node.next[0]
        initial = self._size
        while node and node.score >= minval:
            if ((include_max and node.score > maxval) or
                    (not include_max and node.score >= maxval)):
                break
            next = node.next[0]
            self._remove_node(node, chain)
            if callback:
                callback(node.score, node.value)
            node = next
        return initial - self._size