code: def load_layer_without_provider(layer_uri, layer_name='tmp'):
      
      # Let's try the most common vector driver
      layer = QgsVectorLayer(layer_uri, layer_name, VECTOR_DRIVERS[0])
      if layer.isValid():
          return layer
  
      # Let's try the most common raster driver
      layer = QgsRasterLayer(layer_uri, layer_name, RASTER_DRIVERS[0])
      if layer.isValid():
          return layer
  
      # Then try all other drivers
      for driver in VECTOR_DRIVERS[1:]:
          if driver == 'delimitedtext':
              # Explicitly use URI with delimiter or tests fail in Windows. TS.
              layer = QgsVectorLayer(
                  'file:///%s?delimiter=,' % layer_uri, layer_name, driver)
              if layer.isValid():
                  return layer
          layer = QgsVectorLayer(layer_uri, layer_name, driver)
          if layer.isValid():
              return layer
  
      for driver in RASTER_DRIVERS[1:]:
          layer = QgsRasterLayer(layer_uri, layer_name, driver)
          if layer.isValid():
              return layer
  
      return None
docs: Helper to load a layer when don't know the driver.
  
      Don't use it, it's an empiric function to try each provider one per one.
  
      OGR/GDAL is printing a lot of error saying that the layer is not valid.
  
      :param layer_uri: Layer URI that will be used by QGIS to load the layer.
      :type layer_uri: basestring
  
      :param layer_name: Layer name to use. Default to 'tmp'.
      :type layer_name: basestring
  
      :return: The layer or None if it's failed.
      :rtype: QgsMapLayer