code: def _grouping_intervals(grouping):
      last_interval = None
      for interval in grouping:
          # if grouping is -1, we are done
          if interval == CHAR_MAX:
              return
          # 0: re-use last group ad infinitum
          if interval == 0:
              if last_interval is None:
                  raise ValueError("invalid grouping")
              while True:
                  yield last_interval
          yield interval
          last_interval = interval
  
imports: import sys
  import encodings
  import encodings.aliases
  import re
  import _collections_abc
  from builtins import str
  import functools
label_desc: Use image node_id 4 for calling a global function with example usage: _grouping_intervals(grouping) without return types