docstr: This method is called when clients instantiate a Component and
  runs before __new__ and __init__.
docstr_tok: ["This","method","is","called","when","clients","instantiate","a","Component","and","runs","before","__new__","and","__init__","."]
code: def __call__(cls, *args, **kwargs):
      """
      This method is called when clients instantiate a Component and
      runs before __new__ and __init__.
      """
      # This will call __new__ then __init__, giving us back the Component instance
      instance = super().__call__(*args, **kwargs)
  
      # Before returning, we have the chance to modify the newly created
      # Component instance, so we take the chance and set up the I/O sockets
  
      # If `component.set_output_types()` was called in the component constructor,
      # `__canals_output__` is already populated, no need to do anything.
      if not hasattr(instance, "__canals_output__"):
          # If that's not the case, we need to populate `__canals_output__`
          #
          # If the `run` method was decorated, it has a `_output_types_cache` field assigned
          # that stores the output specification.
          # We deepcopy the content of the cache to transfer ownership from the class method
          # to the actual instance, so that different instances of the same class won't share this data.
          instance.__canals_output__ = deepcopy(
              getattr(instance.run, "_output_types_cache", {})
          )
  
      # Create the sockets if set_input_types() wasn't called in the constructor.
      # If it was called and there are some parameters also in the `run()` method, these take precedence.
      if not hasattr(instance, "__canals_input__"):
          instance.__canals_input__ = {}
      run_signature = inspect.signature(getattr(cls, "run"))
      for param in list(run_signature.parameters)[
          1:
      ]:  # First is 'self' and it doesn't matter.
          if run_signature.parameters[param].kind not in (
              inspect.Parameter.VAR_POSITIONAL,
              inspect.Parameter.VAR_KEYWORD,
          ):  # ignore variable args
              socket_kwargs = {
                  "name": param,
                  "type": run_signature.parameters[param].annotation,
              }
              if (
                  run_signature.parameters[param].default
                  != inspect.Parameter.empty
              ):
                  socket_kwargs[
                      "default_value"
                  ] = run_signature.parameters[param].default
              instance.__canals_input__[param] = InputSocket(
                  **socket_kwargs
              )
      return instance
  
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 1 for calling the ComponentMeta obj's underlying member method code with example usage: obj.__call__(cls) and returns: instance