<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def scoped_variables(self, scoped_variables):
 """ Setter for _scoped_variables field See property :param dict scoped_variables: Dictionary scoped_variables[data_port_id] of :class:`rafcon.core.scope.ScopedVariable` :raises exceptions.TypeError: if the scoped_variables parameter has the wrong type :raises exceptions.AttributeError: if the keys of the scoped_variables dictionary and the ids of the scoped variables in the dictionary do not match """

        if not isinstance(scoped_variables, dict):
            raise TypeError("scoped_variables must be of type dict")
        if [sv_id for sv_id, sv in scoped_variables.items() if not isinstance(sv, ScopedVariable)]:
            raise TypeError("element of scope variable must be of type ScopedVariable")
        if [sv_id for sv_id, sv in scoped_variables.items() if not sv_id == sv.data_port_id]:
            raise AttributeError("The key of the scope variable dictionary and "
                                 "the id of the scope variable do not match")

        old_scoped_variables = self._scoped_variables
        self._scoped_variables = scoped_variables
        for port_id, scoped_variable in scoped_variables.items():
            try:
                scoped_variable.parent = self
            except ValueError:
                self._scoped_variables = old_scoped_variables
                raise

        # check that all old_scoped_variables are no more referencing self as there parent
        for old_scoped_variable in old_scoped_variables.values():
            if old_scoped_variable not in self._scoped_variables.values() and old_scoped_variable.parent is self:
                old_scoped_variable.parent = None