code: def _add_slice(
      dataset,
      groups,
      sample_collection,
      group_field,
      group_key,
      group_slice,
  ):
      tmp = sample_collection.exists(group_key).clone()
  
      try:
          tmp.set_values(
              group_field,
              [
                  groups[k].element(group_slice)
                  for k in tmp.values(group_key)
              ],
          )
          dataset.add_collection(tmp)
      finally:
          tmp.delete()
  
label_desc: Use image node_id 2 for calling a global function with example usage: _add_slice(dataset, groups, sample_collection, group_field, group_key, group_slice) without return types