docstr: Runs the pipeline with given input data.
  
  :param data: A dictionary of inputs for the pipeline's components. Each key is a component name
  and its value is a dictionary of that component's input parameters.
  :param debug: Set to True to collect and return debug information.
  :return: A dictionary containing the pipeline's output.
  :raises PipelineRuntimeError: If a component fails or returns unexpected output.
  
  Example a - Using named components:
  Consider a 'Hello' component that takes a 'word' input and outputs a greeting.
  
  ```python
  @component
  class Hello:
      @component.output_types(output=str)
      def run(self, word: str):
          return {"output": f"Hello, {word}!"}
  ```
  
  Create a pipeline with two 'Hello' components connected together:
  
  ```python
  pipeline = Pipeline()
  pipeline.add_component("hello", Hello())
  pipeline.add_component("hello2", Hello())
  pipeline.connect("hello.output", "hello2.word")
  result = pipeline.run(data={"hello": {"word": "world"}})
  ```
  
  This runs the pipeline with the specified input for 'hello', yielding
  {'hello2': {'output': 'Hello, Hello, world!!'}}.
  
  Example b - Using flat inputs:
  You can also pass inputs directly without specifying component names:
  
  ```python
  result = pipeline.run(data={"word": "world"})
  ```
  
  The pipeline resolves inputs to the correct components, returning
  {'hello2': {'output': 'Hello, Hello, world!!'}}.
docstr_tok: ["Runs","the","pipeline","with","given","input","data",".",":","param","data",":","A","dictionary","of","inputs","for","the","pipeline","'s","components",".","Each","key","is","a","component","name","and","its","value","is","a","dictionary","of","that","component","'s","input","parameters",".",":","param","debug",":","Set","to","True","to","collect","and","return","debug","information",".",":","return",":","A","dictionary","containing","the","pipeline","'s","output",".",":","raises","PipelineRuntimeError",":","If","a","component","fails","or","returns","unexpected","output",".","Example","a","-","Using","named","components",":","Consider","a","'Hello","'","component","that","takes","a","'word","'","input","and","outputs","a","greeting",".","``","`","python","@","component","class","Hello",":","@","component.output_types","(","output=str",")","def","run","(","self",",","word",":","str",")",":","return","{","``","output","''",":","f","''","Hello",",","{","word","}","!","''","}","``","`","Create","a","pipeline","with","two","'Hello","'","components","connected","together",":","``","`","python","pipeline","=","Pipeline","(",")","pipeline.add_component","(","``","hello","''",",","Hello","(",")",")","pipeline.add_component","(","``","hello2","''",",","Hello","(",")",")","pipeline.connect","(","``","hello.output","''",",","``","hello2.word","''",")","result","=","pipeline.run","(","data=","{","``","hello","''",":","{","``","word","''",":","``","world","''","}","}",")","``","`","This","runs","the","pipeline","with","the","specified","input","for","'hello","'",",","yielding","{","'hello2","'",":","{","'output","'",":","'Hello",",","Hello",",","world","!","!","'","}","}",".","Example","b","-","Using","flat","inputs",":","You","can","also","pass","inputs","directly","without","specifying","component","names",":","``","`","python","result","=","pipeline.run","(","data=","{","``","word","''",":","``","world","''","}",")","``","`","The","pipeline","resolves","inputs","to","the","correct","components",",","returning","{","'hello2","'",":","{","'output","'",":","'Hello",",","Hello",",","world","!","!","'","}","}","."]
code: def run(
      self, data: Dict[str, Any], debug: bool = False
  ) -> Dict[str, Any]:
      """
      Runs the pipeline with given input data.
  
      :param data: A dictionary of inputs for the pipeline's components. Each key is a component name
      and its value is a dictionary of that component's input parameters.
      :param debug: Set to True to collect and return debug information.
      :return: A dictionary containing the pipeline's output.
      :raises PipelineRuntimeError: If a component fails or returns unexpected output.
  
      Example a - Using named components:
      Consider a 'Hello' component that takes a 'word' input and outputs a greeting.
  
      ```python
      @component
      class Hello:
          @component.output_types(output=str)
          def run(self, word: str):
              return {"output": f"Hello, {word}!"}
      ```
  
      Create a pipeline with two 'Hello' components connected together:
  
      ```python
      pipeline = Pipeline()
      pipeline.add_component("hello", Hello())
      pipeline.add_component("hello2", Hello())
      pipeline.connect("hello.output", "hello2.word")
      result = pipeline.run(data={"hello": {"word": "world"}})
      ```
  
      This runs the pipeline with the specified input for 'hello', yielding
      {'hello2': {'output': 'Hello, Hello, world!!'}}.
  
      Example b - Using flat inputs:
      You can also pass inputs directly without specifying component names:
  
      ```python
      result = pipeline.run(data={"word": "world"})
      ```
  
      The pipeline resolves inputs to the correct components, returning
      {'hello2': {'output': 'Hello, Hello, world!!'}}.
      """
      # check whether the data is a nested dictionary of component inputs where each key is a component name
      # and each value is a dictionary of input parameters for that component
      is_nested_component_input = all(
          isinstance(value, dict) for value in data.values()
      )
      if is_nested_component_input:
          return self._run_internal(data=data, debug=debug)
      else:
          # flat input, a dict where keys are input names and values are the corresponding values
          # we need to convert it to a nested dictionary of component inputs and then run the pipeline
          # just like in the previous case
          (
              pipeline_inputs,
              unresolved_inputs,
          ) = self._prepare_component_input_data(data)
          if unresolved_inputs:
              logger.warning(
                  "Inputs %s were not matched to any component inputs, please check your run parameters.",
                  list(unresolved_inputs.keys()),
              )
  
          return self._run_internal(data=pipeline_inputs, debug=debug)
  
file_path: haystack/haystack/pipeline.py
imports: from collections import defaultdict
  from typing import Any, Dict, Optional, Union, TextIO, Tuple
  from pathlib import Path
  import datetime
  import logging
  from haystack.core.pipeline import Pipeline
  from haystack.telemetry import pipeline_running
  from haystack.marshal import Marshaller, YamlMarshaller
label_desc: Use image node_id 2 for calling the Pipeline obj's underlying member method code with example usage: obj.run(data, debug) and returns: self, self