code: def hlg_layer(hlg: HighLevelGraph, prefix: str) -> Layer:
      "Get the first layer from a HighLevelGraph whose name starts with a prefix"
      for key, lyr in hlg.layers.items():
          if key.startswith(prefix):
              return lyr
      raise KeyError(
          f"No layer starts with {prefix!r}: {list(hlg.layers)}"
      )
  
imports: from __future__ import annotations
  import contextlib
  import importlib
  import time
  from typing import TYPE_CHECKING
label_desc: Use image node_id 6 for calling a global function with example usage: hlg_layer(hlg, prefix) and returns: lyr