code: def scheduler_story(
      keys_or_stimuli: set[Key | str],
      transition_log: Iterable[Transition],
  ) -> list[Transition]:
      """Creates a story from the scheduler transition log given a set of keys
      describing tasks or stimuli.
  
      Parameters
      ----------
      keys_or_stimuli : set[str]
          Task keys or stimulus_id's
      log : iterable
          The scheduler transition log
  
      Returns
      -------
      story : list[tuple]
      """
      return [
          t
          for t in transition_log
          if t[0] in keys_or_stimuli
          or keys_or_stimuli.intersection(t[3])
      ]
  
imports: from __future__ import annotations
  from collections.abc import Collection, Iterable
  from typing import TYPE_CHECKING
  from dask.typing import Key
label_desc: Use image node_id 1 for calling a global function with example usage: scheduler_story(keys_or_stimuli, transition_log) and returns: unknown