class_docstr: High level graph layer
  
  This abstract class establish a protocol for high level graph layers.
  
  The main motivation of a layer is to represent a collection of tasks
  symbolically in order to speedup a series of operations significantly.
  Ideally, a layer should stay in this symbolic state until execution
  but in practice some operations will force the layer to generate all
  its internal tasks. We say that the layer has been materialized.
  
  Most of the default implementations in this class will materialize the
  layer. It is up to derived classes to implement non-materializing
  implementations.
class_docstr_tok: ["High","level","graph","layer","This","abstract","class","establish","a","protocol","for","high","level","graph","layers",".","The","main","motivation","of","a","layer","is","to","represent","a","collection","of","tasks","symbolically","in","order","to","speedup","a","series","of","operations","significantly",".","Ideally",",","a","layer","should","stay","in","this","symbolic","state","until","execution","but","in","practice","some","operations","will","force","the","layer","to","generate","all","its","internal","tasks",".","We","say","that","the","layer","has","been","materialized",".","Most","of","the","default","implementations","in","this","class","will","materialize","the","layer",".","It","is","up","to","derived","classes","to","implement","non-materializing","implementations","."]
docstr: Clone selected keys in the layer, as well as references to keys in other
  layers
  
  Parameters
  ----------
  keys
      Keys to be replaced. This never includes keys not listed by
      :meth:`get_output_keys`. It must also include any keys that are outside
      of this layer that may be referenced by it.
  seed
      Common hashable used to alter the keys; see :func:`dask.base.clone_key`
  bind_to
      Optional key to bind the leaf nodes to. A leaf node here is one that does
      not reference any replaced keys; in other words it's a node where the
      replacement graph traversal stops; it may still have dependencies on
      non-replaced nodes.
      A bound node will not be computed until after ``bind_to`` has been computed.
  
  Returns
  -------
  - New layer
  - True if the ``bind_to`` key was injected anywhere; False otherwise
  
  Notes
  -----
  This method should be overridden by subclasses to avoid materializing the layer.
code: def clone(
      self,
      keys: set,
      seed: Hashable,
      bind_to: Key | None = None,
  ) -> tuple[Layer, bool]:
      """Clone selected keys in the layer, as well as references to keys in other
      layers
  
      Parameters
      ----------
      keys
          Keys to be replaced. This never includes keys not listed by
          :meth:`get_output_keys`. It must also include any keys that are outside
          of this layer that may be referenced by it.
      seed
          Common hashable used to alter the keys; see :func:`dask.base.clone_key`
      bind_to
          Optional key to bind the leaf nodes to. A leaf node here is one that does
          not reference any replaced keys; in other words it's a node where the
          replacement graph traversal stops; it may still have dependencies on
          non-replaced nodes.
          A bound node will not be computed until after ``bind_to`` has been computed.
  
      Returns
      -------
      - New layer
      - True if the ``bind_to`` key was injected anywhere; False otherwise
  
      Notes
      -----
      This method should be overridden by subclasses to avoid materializing the layer.
      """
      from dask.graph_manipulation import chunks
  
      is_leaf: bool
  
      def clone_value(o):
          """Variant of distributed.utils_comm.subs_multiple, which allows injecting
          bind_to
          """
          nonlocal is_leaf
  
          typ = type(o)
          if typ is tuple and o and callable(o[0]):
              return (o[0],) + tuple(clone_value(i) for i in o[1:])
          elif typ is list:
              return [clone_value(i) for i in o]
          elif typ is dict:
              return {k: clone_value(v) for k, v in o.items()}
          else:
              try:
                  if o not in keys:
                      return o
              except TypeError:
                  return o
              is_leaf = False
              return clone_key(o, seed)
  
      dsk_new = {}
      bound = False
  
      for key, value in self.items():
          if key in keys:
              key = clone_key(key, seed)
              is_leaf = True
              value = clone_value(value)
              if bind_to is not None and is_leaf:
                  value = (chunks.bind, value, bind_to)
                  bound = True
  
          dsk_new[key] = value
  
      return MaterializedLayer(dsk_new), bound
  
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 6 for calling the Layer obj's underlying member method code with example usage: obj.clone(keys, seed, bind_to) and returns: MaterializedLayer,  bound, unknown, unknown, unknown, clone_key, o, o