class_docstr: Scheduler extension for spans support
class_docstr_tok: ["Scheduler","extension","for","spans","support"]
docstr: Yield all spans that contain any of the given tags.
  When a tag is shared both by a span and its (grand)children, only return the
  parent.
docstr_tok: ["Yield","all","spans","that","contain","any","of","the","given","tags",".","When","a","tag","is","shared","both","by","a","span","and","its","(","grand",")","children",",","only","return","the","parent","."]
code: def find_by_tags(self, *tags: str) -> Iterator[Span]:
      """Yield all spans that contain any of the given tags.
      When a tag is shared both by a span and its (grand)children, only return the
      parent.
      """
      by_level = defaultdict(list)
      for tag in tags:
          for sp in self.spans_search_by_tag[tag]:
              by_level[len(sp.name)].append(sp)
  
      seen = set()
      for _, level in sorted(by_level.items()):
          seen.update(level)
          for sp in level:
              if sp.parent not in seen:
                  yield sp
  
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 5 for calling the SpansSchedulerExtension obj's underlying member method code with example usage: obj.find_by_tags() without return types