<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def init_hardware(self, serial=None, device_number=ANY_MODULE):
 """ Initializes the device with the corresponding serial or device number. :param int or None serial: Serial number of the USB-CANmodul. :param int device_number: Device number (0 – 254, or :const:`ANY_MODULE` for the first device). """

        if not self._hw_is_initialized:
            # initialize hardware either by device number or serial
            if serial is None:
                UcanInitHardwareEx(byref(self._handle), device_number, self._callback_ref, None)
            else:
                UcanInitHardwareEx2(byref(self._handle), serial, self._callback_ref, None)
            self._hw_is_initialized = True