code: def layer(self, layer_name):
          
          uri = self.layer_uri(layer_name)
          layer = QgsVectorLayer(uri, layer_name, 'ogr')
          if not layer.isValid():
              layer = QgsRasterLayer(uri, layer_name)
              if not layer.isValid():
                  return False
  
          monkey_patch_keywords(layer)
  
          return layer
docs: Get QGIS layer.
  
          :param layer_name: The name of the layer to fetch.
          :type layer_name: str
  
          :return: The QGIS layer.
          :rtype: QgsMapLayer
  
          .. versionadded:: 4.0