code: def init():
      
      global __dev, __cfg_descr
      devices = get_dfu_devices(idVendor=__VID, idProduct=__PID)
      if not devices:
          raise ValueError('No DFU device found')
      if len(devices) > 1:
          raise ValueError("Multiple DFU devices found")
      __dev = devices[0]
      __dev.set_configuration()
  
      # Claim DFU interface
      usb.util.claim_interface(__dev, __DFU_INTERFACE)
  
      # Find the DFU configuration descriptor, either in the device or interfaces
      __cfg_descr = None
      for cfg in __dev.configurations():
          __cfg_descr = find_dfu_cfg_descr(cfg.extra_descriptors)
          if __cfg_descr:
              break
          for itf in cfg.interfaces():
              __cfg_descr = find_dfu_cfg_descr(itf.extra_descriptors)
              if __cfg_descr:
                  break
  
      # Get device into idle state
      for attempt in range(4):
          status = get_status()
          if status == __DFU_STATE_DFU_IDLE:
              break
          elif (status == __DFU_STATE_DFU_DOWNLOAD_IDLE
              or status == __DFU_STATE_DFU_UPLOAD_IDLE):
              abort_request()
          else:
              clr_status()
docs: Initializes the found DFU device so that we can program it.