class_docstr: Task graph composed of layers of dependent subgraphs
  
  This object encodes a Dask task graph that is composed of layers of
  dependent subgraphs, such as commonly occurs when building task graphs
  using high level collections like Dask array, bag, or dataframe.
  
  Typically each high level array, bag, or dataframe operation takes the task
  graphs of the input collections, merges them, and then adds one or more new
  layers of tasks for the new operation.  These layers typically have at
  least as many tasks as there are partitions or chunks in the collection.
  The HighLevelGraph object stores the subgraphs for each operation
  separately in sub-graphs, and also stores the dependency structure between
  them.
  
  Parameters
  ----------
  layers : Mapping[str, Mapping]
      The subgraph layers, keyed by a unique name
  dependencies : Mapping[str, set[str]]
      The set of layers on which each layer depends
  key_dependencies : dict[Key, set], optional
      Mapping (some) keys in the high level graph to their dependencies. If
      a key is missing, its dependencies will be calculated on-the-fly.
  
  Examples
  --------
  Here is an idealized example that shows the internal state of a
  HighLevelGraph
  
  >>> import dask.dataframe as dd
  
  >>> df = dd.read_csv('myfile.*.csv')  # doctest: +SKIP
  >>> df = df + 100  # doctest: +SKIP
  >>> df = df[df.name == 'Alice']  # doctest: +SKIP
  
  >>> graph = df.__dask_graph__()  # doctest: +SKIP
  >>> graph.layers  # doctest: +SKIP
  {
   'read-csv': {('read-csv', 0): (pandas.read_csv, 'myfile.0.csv'),
                ('read-csv', 1): (pandas.read_csv, 'myfile.1.csv'),
                ('read-csv', 2): (pandas.read_csv, 'myfile.2.csv'),
                ('read-csv', 3): (pandas.read_csv, 'myfile.3.csv')},
   'add': {('add', 0): (operator.add, ('read-csv', 0), 100),
           ('add', 1): (operator.add, ('read-csv', 1), 100),
           ('add', 2): (operator.add, ('read-csv', 2), 100),
           ('add', 3): (operator.add, ('read-csv', 3), 100)}
   'filter': {('filter', 0): (lambda part: part[part.name == 'Alice'], ('add', 0)),
              ('filter', 1): (lambda part: part[part.name == 'Alice'], ('add', 1)),
              ('filter', 2): (lambda part: part[part.name == 'Alice'], ('add', 2)),
              ('filter', 3): (lambda part: part[part.name == 'Alice'], ('add', 3))}
  }
  
  >>> graph.dependencies  # doctest: +SKIP
  {
   'read-csv': set(),
   'add': {'read-csv'},
   'filter': {'add'}
  }
  
  See Also
  --------
  HighLevelGraph.from_collections :
      typically used by developers to make new HighLevelGraphs
class_docstr_tok: ["Task","graph","composed","of","layers","of","dependent","subgraphs","This","object","encodes","a","Dask","task","graph","that","is","composed","of","layers","of","dependent","subgraphs",",","such","as","commonly","occurs","when","building","task","graphs","using","high","level","collections","like","Dask","array",",","bag",",","or","dataframe",".","Typically","each","high","level","array",",","bag",",","or","dataframe","operation","takes","the","task","graphs","of","the","input","collections",",","merges","them",",","and","then","adds","one","or","more","new","layers","of","tasks","for","the","new","operation",".","These","layers","typically","have","at","least","as","many","tasks","as","there","are","partitions","or","chunks","in","the","collection",".","The","HighLevelGraph","object","stores","the","subgraphs","for","each","operation","separately","in","sub-graphs",",","and","also","stores","the","dependency","structure","between","them",".","Parameters","--","--","--","--","--","layers",":","Mapping","[","str",",","Mapping","]","The","subgraph","layers",",","keyed","by","a","unique","name","dependencies",":","Mapping","[","str",",","set","[","str","]","]","The","set","of","layers","on","which","each","layer","depends","key_dependencies",":","dict","[","Key",",","set","]",",","optional","Mapping","(","some",")","keys","in","the","high","level","graph","to","their","dependencies",".","If","a","key","is","missing",",","its","dependencies","will","be","calculated","on-the-fly",".","Examples","--","--","--","--","Here","is","an","idealized","example","that","shows","the","internal","state","of","a","HighLevelGraph",">",">",">","import","dask.dataframe","as","dd",">",">",">","df","=","dd.read_csv","(","'myfile",".","*",".csv","'",")","#","doctest",":","+SKIP",">",">",">","df","=","df","+","100","#","doctest",":","+SKIP",">",">",">","df","=","df","[","df.name","==","'Alice","'","]","#","doctest",":","+SKIP",">",">",">","graph","=","df.__dask_graph__","(",")","#","doctest",":","+SKIP",">",">",">","graph.layers","#","doctest",":","+SKIP","{","'read-csv","'",":","{","(","'read-csv","'",",","0",")",":","(","pandas.read_csv",",","'myfile.0.csv","'",")",",","(","'read-csv","'",",","1",")",":","(","pandas.read_csv",",","'myfile.1.csv","'",")",",","(","'read-csv","'",",","2",")",":","(","pandas.read_csv",",","'myfile.2.csv","'",")",",","(","'read-csv","'",",","3",")",":","(","pandas.read_csv",",","'myfile.3.csv","'",")","}",",","'add","'",":","{","(","'add","'",",","0",")",":","(","operator.add",",","(","'read-csv","'",",","0",")",",","100",")",",","(","'add","'",",","1",")",":","(","operator.add",",","(","'read-csv","'",",","1",")",",","100",")",",","(","'add","'",",","2",")",":","(","operator.add",",","(","'read-csv","'",",","2",")",",","100",")",",","(","'add","'",",","3",")",":","(","operator.add",",","(","'read-csv","'",",","3",")",",","100",")","}","'filter","'",":","{","(","'filter","'",",","0",")",":","(","lambda","part",":","part","[","part.name","==","'Alice","'","]",",","(","'add","'",",","0",")",")",",","(","'filter","'",",","1",")",":","(","lambda","part",":","part","[","part.name","==","'Alice","'","]",",","(","'add","'",",","1",")",")",",","(","'filter","'",",","2",")",":","(","lambda","part",":","part","[","part.name","==","'Alice","'","]",",","(","'add","'",",","2",")",")",",","(","'filter","'",",","3",")",":","(","lambda","part",":","part","[","part.name","==","'Alice","'","]",",","(","'add","'",",","3",")",")","}","}",">",">",">","graph.dependencies","#","doctest",":","+SKIP","{","'read-csv","'",":","set","(",")",",","'add","'",":","{","'read-csv","'","}",",","'filter","'",":","{","'add","'","}","}","See","Also","--","--","--","--","HighLevelGraph.from_collections",":","typically","used","by","developers","to","make","new","HighLevelGraphs"]
docstr: Return a new HighLevelGraph with only the given layers and their
  dependencies. Internally, layers are not modified.
  
  This is a variant of :meth:`HighLevelGraph.cull` which is much faster and does
  not risk creating a collision between two layers with the same name and
  different content when two culled graphs are merged later on.
  
  Returns
  -------
  hlg: HighLevelGraph
      Culled high level graph
code: def cull_layers(self, layers: Iterable[str]) -> HighLevelGraph:
      """Return a new HighLevelGraph with only the given layers and their
      dependencies. Internally, layers are not modified.
  
      This is a variant of :meth:`HighLevelGraph.cull` which is much faster and does
      not risk creating a collision between two layers with the same name and
      different content when two culled graphs are merged later on.
  
      Returns
      -------
      hlg: HighLevelGraph
          Culled high level graph
      """
      to_visit = set(layers)
      ret_layers = {}
      ret_dependencies = {}
      while to_visit:
          k = to_visit.pop()
          ret_layers[k] = self.layers[k]
          ret_dependencies[k] = self.dependencies[k]
          to_visit |= ret_dependencies[k] - ret_dependencies.keys()
  
      return HighLevelGraph(ret_layers, ret_dependencies)
  
imports: from __future__ import annotations
  import abc
  import copy
  import html
  from collections.abc import Collection, Hashable, ItemsView, Iterable, Iterator, KeysView, Mapping, Sequence, Set, ValuesView
  from typing import Any
  import tlz
  import dask
  from dask import config
  from dask.base import clone_key, flatten, is_dask_collection
  from dask.core import keys_in_tasks, reverse_dict
  from dask.typing import DaskCollection, Graph, Key
  from dask.utils import ensure_dict, import_required, key_split
  from dask.widgets import get_template
label_desc: Use image node_id 19 for calling the HighLevelGraph obj's underlying member method code with example usage: obj.cull_layers(layers) and returns: HighLevelGraph