code: def load_layer_from_registry(layer_path):
      
      # reload the layer in case the layer path has no provider information
      the_layer = load_layer(layer_path)[0]
      layers = QgsProject.instance().mapLayers()
      for _, layer in list(layers.items()):
          if full_layer_uri(layer) == full_layer_uri(the_layer):
              monkey_patch_keywords(layer)
              return layer
  
      return the_layer
docs: Helper method to load a layer from registry if its already there.
  
      If the layer is not loaded yet, it will create the QgsMapLayer on the fly.
  
      :param layer_path: Layer source path.
      :type layer_path: str
  
      :return: Vector layer
      :rtype: QgsVectorLayer
  
      .. versionadded: 4.3.0