<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_peer(self, peer):
 """Remove the peer from the heap. Return: removed peer if peer exists. If peer's index is out of range, raise IndexError. """

        if peer.index < 0 or peer.index >= self.size():
            raise IndexError('Peer index is out of range')

        assert peer is self.peers[peer.index], "peer is not in the heap"

        return heap.remove(self, peer.index)