code: def has_tasks(dsk, x):
      """Whether ``x`` has anything to compute.
  
      Returns True if:
      - ``x`` is a task
      - ``x`` is a key in ``dsk``
      - ``x`` is a list that contains any tasks or keys
      """
      if istask(x):
          return True
      try:
          if x in dsk:
              return True
      except Exception:
          pass
      if isinstance(x, list):
          for i in x:
              if has_tasks(dsk, i):
                  return True
      return False
  
imports: from __future__ import annotations
  from collections import defaultdict
  from collections.abc import Collection, Iterable, Mapping
  from typing import Any, Literal, TypeVar, cast, overload
  from dask.typing import Graph, Key, NoDefault, no_default
label_desc: Use image node_id 3 for calling a global function with example usage: has_tasks(dsk, x) and returns: False, True, True, True