code: def test_minimal_graph_schema():
      def test_schema_node(
          needs: Dict[Text, Text], target: bool = False
      ) -> SchemaNode:
          return SchemaNode(
              needs=needs,
              uses=None,
              fn="",
              constructor_name="",
              config={},
              is_target=target,
          )
  
      test_schema = GraphSchema(
          {
              "1": test_schema_node({"i": "3"}, True),
              "2": test_schema_node({"i": "3"}),
              "3": test_schema_node({"i": "4"}),
              "4": test_schema_node({}),
              "5": test_schema_node({"i": "6"}),
              "6": test_schema_node({}),
              "7": test_schema_node({}),
              "8": test_schema_node({"i": "9"}, True),
              "9": test_schema_node({"i": "__input__"}),
          }
      )
      assert test_schema.minimal_graph_schema() == GraphSchema(
          {
              "1": test_schema_node({"i": "3"}, True),
              "3": test_schema_node({"i": "4"}),
              "4": test_schema_node({}),
              "8": test_schema_node({"i": "9"}, True),
              "9": test_schema_node({"i": "__input__"}),
          }
      )
  
      assert test_schema.minimal_graph_schema(
          targets=["8"]
      ) == GraphSchema(
          {
              "8": test_schema_node({"i": "9"}, True),
              "9": test_schema_node({"i": "__input__"}),
          }
      )
  
file_path: rasa/tests/engine/test_graph.py
imports: from __future__ import annotations
  from pathlib import Path
  from typing import Dict, Text
  import pytest
  from rasa.engine.storage.resource import Resource
  import rasa.shared.utils.io
  from rasa.engine.exceptions import GraphSchemaException
  from rasa.engine.graph import SchemaNode, GraphSchema
  from tests.engine.graph_components_test_classes import PersistableTestComponent
label_desc: Use image node_id 3 for calling a global function with example usage: test_minimal_graph_schema() and returns: SchemaNode