code: def test_multibar_with_spans(client):
      """Test progress(group_by='spans'"""
      with span("span 1"):
          L = client.map(inc, range(100))
      with span("span 2"):
          L2 = client.map(dec, L)
      with span("span 3"):
          L3 = client.map(add, L, L2)
      with span("other span"):
          _ = client.submit(inc, 123)
      e = client.submit(throws, L3)
  
      p = progress(
          e, complete=True, multi=True, notebook=True, group_by="spans"
      )
      client.sync(p.listen)
  
      # keys are tuples of (group_name, group_id), just get names
      bar_items = {k[0]: v.value for k, v in p.bars.items()}
      bar_texts = {k[0]: v.value for k, v in p.bar_texts.items()}
      bar_labels = {k[0]: v.value for k, v in p.bar_labels.items()}
  
      assert bar_items == {
          "span 1": 1,
          "span 2": 1,
          "span 3": 1,
          "default": 0,
      }
      assert bar_texts.keys() == {
          "span 1",
          "span 2",
          "span 3",
          "default",
      }
      assert all(
          "100 / 100" in v
          for k, v in bar_texts.items()
          if k != "default"
      )
      assert bar_labels.keys() == {
          "span 1",
          "span 2",
          "span 3",
          "default",
      }
      assert all(f">{k}<" in v for k, v in bar_labels.items())
  
file_path: distributed/distributed/diagnostics/tests/test_progress_widgets.py
imports: from __future__ import annotations
  import re
  from operator import add
  import pytest
  from dask.utils import key_split
  from distributed.client import wait
  from distributed.spans import span
  from distributed.utils_test import dec, gen_cluster, gen_tls_cluster, inc, throws
  from distributed.diagnostics.progressbar import MultiProgressWidget, ProgressWidget, progress
label_desc: Use image node_id 5 for calling a global function with example usage: test_multibar_with_spans(client) without return types