code: def consecutive(data, mode="first", stepsize=1):
      group = np.split(data, np.where(np.diff(data) != stepsize)[0] + 1)
      group = [item for item in group if len(item) > 0]
  
      if mode == "first":
          result = [l[0] for l in group]
      elif mode == "last":
          result = [l[-1] for l in group]
      return result
  
imports: import torch
  import pickle
  import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: consecutive(data, mode, stepsize) and returns: result