code: def test_fuse_subgraphs():
      dsk = {
          "x-1": 1,
          "inc-1": (inc, "x-1"),
          "inc-2": (inc, "inc-1"),
          "add-1": (add, "x-1", "inc-2"),
          "inc-3": (inc, "add-1"),
          "inc-4": (inc, "inc-3"),
          "add-2": (add, "add-1", "inc-4"),
          "inc-5": (inc, "add-2"),
          "inc-6": (inc, "inc-5"),
      }
  
      res = fuse(dsk, "inc-6", fuse_subgraphs=True)
      sol = with_deps(
          {
              "inc-6": "add-inc-x-1",
              "add-inc-x-1": (
                  SubgraphCallable(
                      {
                          "x-1": 1,
                          "add-1": (add, "x-1", (inc, (inc, "x-1"))),
                          "inc-6": (
                              inc,
                              (
                                  inc,
                                  (add, "add-1", (inc, (inc, "add-1"))),
                              ),
                          ),
                      },
                      "inc-6",
                      (),
                  ),
              ),
          }
      )
      assert res == sol
  
      res = fuse(dsk, "inc-6", fuse_subgraphs=True, rename_keys=False)
      sol = with_deps(
          {
              "inc-6": (
                  SubgraphCallable(
                      {
                          "x-1": 1,
                          "add-1": (add, "x-1", (inc, (inc, "x-1"))),
                          "inc-6": (
                              inc,
                              (
                                  inc,
                                  (add, "add-1", (inc, (inc, "add-1"))),
                              ),
                          ),
                      },
                      "inc-6",
                      (),
                  ),
              )
          }
      )
      assert res == sol
  
      res = fuse(dsk, "add-2", fuse_subgraphs=True)
      sol = with_deps(
          {
              "add-inc-x-1": (
                  SubgraphCallable(
                      {
                          "x-1": 1,
                          "add-1": (add, "x-1", (inc, (inc, "x-1"))),
                          "add-2": (
                              add,
                              "add-1",
                              (inc, (inc, "add-1")),
                          ),
                      },
                      "add-2",
                      (),
                  ),
              ),
              "add-2": "add-inc-x-1",
              "inc-6": (inc, (inc, "add-2")),
          }
      )
      assert res == sol
  
      res = fuse(dsk, "inc-2", fuse_subgraphs=True)
      # ordering of arguments is unstable, check all permutations
      sols = []
      for inkeys in itertools.permutations(("x-1", "inc-2")):
          sols.append(
              with_deps(
                  {
                      "x-1": 1,
                      "inc-2": (inc, (inc, "x-1")),
                      "inc-6": "inc-add-1",
                      "inc-add-1": (
                          SubgraphCallable(
                              {
                                  "add-1": (add, "x-1", "inc-2"),
                                  "inc-6": (
                                      inc,
                                      (
                                          inc,
                                          (
                                              add,
                                              "add-1",
                                              (inc, (inc, "add-1")),
                                          ),
                                      ),
                                  ),
                              },
                              "inc-6",
                              inkeys,
                          ),
                      )
                      + inkeys,
                  }
              )
          )
      assert res in sols
  
      res = fuse(dsk, ["inc-2", "add-2"], fuse_subgraphs=True)
      # ordering of arguments is unstable, check all permutations
      sols = []
      for inkeys in itertools.permutations(("x-1", "inc-2")):
          sols.append(
              with_deps(
                  {
                      "x-1": 1,
                      "inc-2": (inc, (inc, "x-1")),
                      "inc-add-1": (
                          SubgraphCallable(
                              {
                                  "add-1": (add, "x-1", "inc-2"),
                                  "add-2": (
                                      add,
                                      "add-1",
                                      (inc, (inc, "add-1")),
                                  ),
                              },
                              "add-2",
                              inkeys,
                          ),
                      )
                      + inkeys,
                      "add-2": "inc-add-1",
                      "inc-6": (inc, (inc, "add-2")),
                  }
              )
          )
      assert res in sols
  
imports: import itertools
  import pickle
  from functools import partial
  import pytest
  from flash.core.serve.dag.optimization import SubgraphCallable, cull, functions_of, fuse, fuse_linear, inline, inline_functions
  from flash.core.serve.dag.task import get, get_dependencies
  from flash.core.serve.dag.utils import apply, partial_by_order
  from flash.core.serve.dag.utils_test import add, inc
  from flash.core.utilities.imports import _TOPIC_SERVE_AVAILABLE
label_desc: Use image node_id 22 for calling a global function with example usage: test_fuse_subgraphs() without return types