docstr: The number of tasks currently in each state in this span tree;
  e.g. ``{"memory": 10, "processing": 3, "released": 4, ...}``.
  
  See Also
  --------
  distributed.scheduler.TaskGroup.states
docstr_tok: ["The","number","of","tasks","currently","in","each","state","in","this","span","tree",";","e.g",".","``","{","``","memory","''",":","10",",","``","processing","''",":","3",",","``","released","''",":","4",",","...","}","``",".","See","Also","--","--","--","--","distributed.scheduler.TaskGroup.states"]
code: def states(self) -> dict[TaskStateState, int]:
      """The number of tasks currently in each state in this span tree;
      e.g. ``{"memory": 10, "processing": 3, "released": 4, ...}``.
  
      See Also
      --------
      distributed.scheduler.TaskGroup.states
      """
      return sum_mappings(tg.states for tg in self.traverse_groups())
  
imports: from __future__ import annotations
  import uuid
  import weakref
  from collections import defaultdict
  from collections.abc import Hashable, Iterable, Iterator
  from contextlib import contextmanager
  from itertools import islice
  from typing import TYPE_CHECKING, Any
  import dask.config
  from dask.typing import Key
  from distributed.collections import sum_mappings
  from distributed.itertools import ffill
  from distributed.metrics import time
label_desc: Use image node_id 9 for calling the Span obj's underlying member method code with example usage: obj.states() and returns: sum_mappings