class_docstr: See module's docstring.
  
  Args:
      class_: the class that Canals should use as a component.
      serializable: whether to check, at init time, if the component can be saved with
      `save_pipelines()`.
  
  Returns:
      A class that can be recognized as a component.
  
  Raises:
      ComponentError: if the class provided has no `run()` method or otherwise doesn't respect the component contract.
class_docstr_tok: ["See","module","'s","docstring",".","Args",":","class_",":","the","class","that","Canals","should","use","as","a","component",".","serializable",":","whether","to","check",",","at","init","time",",","if","the","component","can","be","saved","with","`","save_pipelines","(",")","`",".","Returns",":","A","class","that","can","be","recognized","as","a","component",".","Raises",":","ComponentError",":","if","the","class","provided","has","no","`","run","(",")","`","method","or","otherwise","does","n't","respect","the","component","contract","."]
docstr: Decorator validating the structure of the component and registering it in the components registry.
docstr_tok: ["Decorator","validating","the","structure","of","the","component","and","registering","it","in","the","components","registry","."]
code: def _component(self, class_):
      """
      Decorator validating the structure of the component and registering it in the components registry.
      """
      logger.debug("Registering %s as a component", class_)
  
      # Check for required methods and fail as soon as possible
      if not hasattr(class_, "run"):
          raise ComponentError(
              f"{class_.__name__} must have a 'run()' method. See the docs for more information."
          )
  
      def copy_class_namespace(namespace):
          """
          This is the callback that `typing.new_class` will use
          to populate the newly created class. We just copy
          the whole namespace from the decorated class.
          """
          for key, val in dict(class_.__dict__).items():
              # __dict__ and __weakref__ are class-bound, we should let Python recreate them.
              if key in ("__dict__", "__weakref__"):
                  continue
              namespace[key] = val
  
      # Recreate the decorated component class so it uses our metaclass
      class_ = new_class(
          class_.__name__,
          class_.__bases__,
          {"metaclass": ComponentMeta},
          copy_class_namespace,
      )
  
      # Save the component in the class registry (for deserialization)
      class_path = f"{class_.__module__}.{class_.__name__}"
      if class_path in self.registry:
          # Corner case, but it may occur easily in notebooks when re-running cells.
          logger.debug(
              "Component %s is already registered. Previous imported from '%s', new imported from '%s'",
              class_path,
              self.registry[class_path],
              class_,
          )
      self.registry[class_path] = class_
      logger.debug("Registered Component %s", class_)
  
      return class_
  
imports: import logging
  import inspect
  from typing import Protocol, runtime_checkable, Any
  from types import new_class
  from copy import deepcopy
  from haystack.core.component.sockets import InputSocket, OutputSocket, _empty
  from haystack.core.errors import ComponentError
label_desc: Use image node_id 6 for calling the _Component obj's underlying member method code with example usage: obj._component(class_) and returns: class_