code: def test_from_dict():
      data = {
          "metadata": {"test": "test"},
          "max_loops_allowed": 101,
          "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",
              },
          ],
      }
      pipe = Pipeline.from_dict(data)
  
      assert pipe.metadata == {"test": "test"}
      assert pipe.max_loops_allowed == 101
  
      # Components
      assert len(pipe.graph.nodes) == 3
      ## add_two
      add_two = pipe.graph.nodes["add_two"]
      assert add_two["instance"].add == 2
      assert add_two["input_sockets"] == {
          "value": InputSocket(name="value", type=int),
          "add": InputSocket(
              name="add", type=Optional[int], default_value=None
          ),
      }
      assert add_two["output_sockets"] == {
          "result": OutputSocket(
              name="result", type=int, receivers=["double"]
          )
      }
      assert add_two["visits"] == 0
  
      ## add_default
      add_default = pipe.graph.nodes["add_default"]
      assert add_default["instance"].add == 1
      assert add_default["input_sockets"] == {
          "value": InputSocket(
              name="value", type=int, senders=["double"]
          ),
          "add": InputSocket(
              name="add", type=Optional[int], default_value=None
          ),
      }
      assert add_default["output_sockets"] == {
          "result": OutputSocket(name="result", type=int)
      }
      assert add_default["visits"] == 0
  
      ## double
      double = pipe.graph.nodes["double"]
      assert double["instance"]
      assert double["input_sockets"] == {
          "value": InputSocket(
              name="value", type=int, senders=["add_two"]
          )
      }
      assert double["output_sockets"] == {
          "value": OutputSocket(
              name="value", type=int, receivers=["add_default"]
          )
      }
      assert double["visits"] == 0
  
      # Connections
      connections = list(pipe.graph.edges(data=True))
      assert len(connections) == 2
      assert connections[0] == (
          "add_two",
          "double",
          {
              "conn_type": "int",
              "from_socket": OutputSocket(
                  name="result", type=int, receivers=["double"]
              ),
              "to_socket": InputSocket(
                  name="value", type=int, senders=["add_two"]
              ),
              "mandatory": True,
          },
      )
      assert connections[1] == (
          "double",
          "add_default",
          {
              "conn_type": "int",
              "from_socket": OutputSocket(
                  name="value", type=int, receivers=["add_default"]
              ),
              "to_socket": InputSocket(
                  name="value", type=int, senders=["double"]
              ),
              "mandatory": True,
          },
      )
  
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 4 for calling a global function with example usage: test_from_dict() without return types