code: def collapse_repeated(
      lst, *, collapser, mapper=identity, key=identity
  ):
      keyed = list(map(key, lst))
      for is_highlighted, group in itertools.groupby(
          zip(lst, highlight_unique(keyed)),
          key=lambda t: t[1][1],
      ):
          original_group, highlighted_group = zip(*group)
          if is_highlighted:
              yield from map(mapper, original_group)
          else:
              keyed_group, _ = zip(*highlighted_group)
              yield collapser(list(original_group), list(keyed_group))
  
imports: import ast
  import itertools
  import types
  from collections import OrderedDict, Counter, defaultdict
  from types import FrameType, TracebackType
  from typing import Iterator, List, Tuple, Iterable, Callable, Union, TypeVar, Mapping
  from asttokens import ASTText
label_desc: Use image node_id 6 for calling a global function with example usage: collapse_repeated(lst) without return types