code: def groupby_apply(
      data: typing.Iterable[typing.Any],
      keyfunc: typing.Callable,
      applyfunc: typing.Callable,
  ) -> typing.List[typing.Tuple[typing.Any, typing.Any]]:
      """
      GroupBy using a key function and an apply function, without a `pandas`
      dependency.
      See: <https://docs.python.org/3/library/itertools.html#itertools.groupby>
  
          data:
      iterable
  
          keyfunc:
      callable to define the key by which you want to group
  
          applyfunc:
      callable to apply to the group
  
          returns:
      an iterable with the accumulated values
      """
      data = sorted(data, key=keyfunc)
  
      accum: typing.List[typing.Tuple[typing.Any, typing.Any]] = [
          (
              k,
              applyfunc(g),
          )
          for k, g in itertools.groupby(data, keyfunc)
      ]
  
      return accum
  
file_path: pytextrank/pytextrank/util.py
imports: import itertools
  import re
  import string
  import typing
  import unicodedata
  from spacy.tokens import Span
label_desc: Use image node_id 1 for calling a global function with example usage: groupby_apply(data, keyfunc, applyfunc) and returns: accum