class_docstr: Accumulates the value flowing through the connection into an internal attribute.
  The sum function can be customized.
  
  Example of how to deal with serialization when some of the parameters
  are not directly serializable.
class_docstr_tok: ["Accumulates","the","value","flowing","through","the","connection","into","an","internal","attribute",".","The","sum","function","can","be","customized",".","Example","of","how","to","deal","with","serialization","when","some","of","the","parameters","are","not","directly","serializable","."]
docstr: :param function: the function to use to accumulate the values.
      The function must take exactly two values.
      If it's a callable, it's used as it is.
      If it's a string, the component will look for it in sys.modules and
      import it at need. This is also a parameter.
docstr_tok: [":","param","function",":","the","function","to","use","to","accumulate","the","values",".","The","function","must","take","exactly","two","values",".","If","it","'s","a","callable",",","it","'s","used","as","it","is",".","If","it","'s","a","string",",","the","component","will","look","for","it","in","sys.modules","and","import","it","at","need",".","This","is","also","a","parameter","."]
code: def __init__(self, function: Optional[Callable] = None):
      """
      :param function: the function to use to accumulate the values.
          The function must take exactly two values.
          If it's a callable, it's used as it is.
          If it's a string, the component will look for it in sys.modules and
          import it at need. This is also a parameter.
      """
      self.state = 0
      self.function: Callable = (
          _default_function if function is None else function
      )
  
file_path: haystack/haystack/testing/sample_components/accumulate.py
imports: from typing import Callable, Optional, Dict, Any
  import sys
  import builtins
  from importlib import import_module
  from haystack.core.serialization import default_to_dict
  from haystack.core.component import component
  from haystack.core.errors import ComponentDeserializationError
label_desc: Use image node_id 1 to create a new Accumulate object  with example: obj = Accumulate(function)