code: def test_pprint_task():
      from dask.diagnostics.profile_visualize import pprint_task
  
      keys = {"a", "b", "c", "d", "e"}
      assert pprint_task((add, "a", 1), keys) == "add(_, *)"
      assert pprint_task((add, (add, "a", 1)), keys) == "add(add(_, *))"
      res = "sum([*, _, add(_, *)])"
      assert pprint_task((sum, [1, "b", (add, "a", 1)]), keys) == res
      assert pprint_task((sum, (1, 2, 3, 4, 5, 6, 7)), keys) == "sum(*)"
  
      assert len(pprint_task((sum, list(keys) * 100), keys)) < 100
      assert (
          pprint_task((sum, list(keys) * 100), keys)
          == "sum([_, _, _, ...])"
      )
      assert (
          pprint_task((sum, [1, 2, (sum, ["a", 4]), 5, 6] * 100), keys)
          == "sum([*, *, sum([_, *]), ...])"
      )
      assert (
          pprint_task(
              (sum, [1, 2, (sum, ["a", (sum, [1, 2, 3])]), 5, 6]), keys
          )
          == "sum([*, *, sum([_, sum(...)]), ...])"
      )
  
      # With kwargs
      def foo(w, x, y=(), z=3):
          return w + x + sum(y) + z
  
      task = (
          apply,
          foo,
          (tuple, ["a", "b"]),
          (dict, [["y", ["a", "b"]], ["z", "c"]]),
      )
      assert pprint_task(task, keys) == "foo(_, _, y=[_, _], z=_)"
      task = (
          apply,
          foo,
          (tuple, ["a", "b"]),
          (dict, [["y", ["a", 1]], ["z", 1]]),
      )
      assert pprint_task(task, keys) == "foo(_, _, y=[_, *], z=*)"
  
imports: from __future__ import annotations
  import contextlib
  import os
  import warnings
  from operator import add, mul
  from timeit import default_timer
  import pytest
  from dask.diagnostics import CacheProfiler, Profiler, ResourceProfiler
  from dask.diagnostics.profile_visualize import BOKEH_VERSION
  from dask.threaded import get
  from dask.utils import apply, tmpfile
  from dask.utils_test import slowadd
label_desc: Use image node_id 9 for calling a global function with example usage: test_pprint_task() and returns: unknown