<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def factory_reset(self, ids, except_ids=False, except_baudrate_and_ids=False):
 """ Reset all motors on the bus to their factory default settings. """


        mode = (0x02 if except_baudrate_and_ids else
                0x01 if except_ids else 0xFF)

        for id in ids:
            try:
                self._send_packet(self._protocol.DxlResetPacket(id, mode))

            except (DxlTimeoutError, DxlCommunicationError):
                pass