code: def test_to_dict():
      add_two = AddFixedValue(add=2)
      add_default = AddFixedValue()
      double = Double()
      pipe = Pipeline(metadata={"test": "test"}, max_loops_allowed=42)
      pipe.add_component("add_two", add_two)
      pipe.add_component("add_default", add_default)
      pipe.add_component("double", double)
      pipe.connect("add_two", "double")
      pipe.connect("double", "add_default")
  
      res = pipe.to_dict()
      expected = {
          "metadata": {"test": "test"},
          "max_loops_allowed": 42,
          "components": {
              "add_two": {
                  "type": "haystack.testing.sample_components.add_value.AddFixedValue",
                  "init_parameters": {"add": 2},
              },
              "add_default": {
                  "type": "haystack.testing.sample_components.add_value.AddFixedValue",
                  "init_parameters": {"add": 1},
              },
              "double": {
                  "type": "haystack.testing.sample_components.double.Double",
                  "init_parameters": {},
              },
          },
          "connections": [
              {"sender": "add_two.result", "receiver": "double.value"},
              {
                  "sender": "double.value",
                  "receiver": "add_default.value",
              },
          ],
      }
      assert res == expected
  
imports: from typing import Optional
  import logging
  import pytest
  from haystack.core.pipeline import Pipeline
  from haystack.core.component.sockets import InputSocket, OutputSocket
  from haystack.core.errors import PipelineMaxLoops, PipelineError, PipelineRuntimeError
  from haystack.testing.sample_components import AddFixedValue, Threshold, Double, Sum
  from haystack.testing.factory import component_class
label_desc: Use image node_id 3 for calling a global function with example usage: test_to_dict() without return types