<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def output_data_ports(self, output_data_ports):
 """ Setter for _output_data_ports field See property :param dict output_data_ports: Dictionary that maps :class:`int` data_port_ids onto values of type :class:`rafcon.core.state_elements.data_port.OutputDataPort` :raises exceptions.TypeError: if the output_data_ports parameter has the wrong type :raises exceptions.AttributeError: if the key of the output dictionary and the id of the data port do not match """

        if not isinstance(output_data_ports, dict):
            raise TypeError("output_data_ports must be of type dict")
        if [port_id for port_id, port in output_data_ports.items() if not port_id == port.data_port_id]:
            raise AttributeError("The key of the output dictionary and the id of the data port do not match")

        # This is a fix for older state machines, which didn't distinguish between input and output ports
        for port_id, port in output_data_ports.items():
            if not isinstance(port, OutputDataPort):
                if isinstance(port, DataPort):
                    port = OutputDataPort(port.name, port.data_type, port.default_value, port.data_port_id)
                    output_data_ports[port_id] = port
                else:
                    raise TypeError("Elements of output_data_ports must be of type OutputDataPort, given: {0}".format(
                        type(port).__name__))

        old_output_data_ports = self._output_data_ports
        self._output_data_ports = output_data_ports
        for port_id, port in output_data_ports.items():
            try:
                port.parent = self
            except ValueError:
                self._output_data_ports = old_output_data_ports
                raise

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