<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_pos_in_delegate(self, index, globalpos):
 """Map the global position to the position relative to the given index :param index: the index to map to :type index: :class:`QtCore.QModelIndex` :param globalpos: the global position :type globalpos: :class:`QtCore.QPoint` :returns: The position relative to the given index :rtype: :class:`QtCore.QPoint` :raises: None """

        rect = self.visualRect(index)  # rect of the index
        p = self.viewport().mapToGlobal(rect.topLeft())
        return globalpos - p