code: def process_dataset_splits(
      dataset, sample_split_fn, save=False, log=True
  ):
      splits = defaultdict(list)
      for sample_id, sample in dataset.samples:
          sample_split = sample_split_fn(sample)
          if sample_split is not None:
              splits[sample_split].append(sample_id)
  
      if log:
          print("Processed {} samples".format(len(dataset.samples)))
          for split_name, split_ids in splits.items():
              print(
                  "Found {} samples for {}".format(
                      len(split_ids), split_name
                  )
              )
  
      if save:
          if log:
              print(
                  "Saving data splits to: {}".format(dataset.split_path)
              )
          dataset.splits = splits
          dataset.dump_splits()
  
      return splits
  
imports: import glob
  import numpy
  import os
  import re
  import tempfile
  from addict import Dict
  from collections import defaultdict
  from pathlib import Path
  from subprocess import call
  import cv2
  from ..dataset import GluonCVMotionDataset, DataSample, FieldNames, get_resized_video_location
  from ..io.video_io import VideoFrameReader, VideoSortedFolderReader, cmd_with_addn_args, FFMPEG_FOURCC
label_desc: Use image node_id 3 for calling a global function with example usage: process_dataset_splits(dataset, sample_split_fn, save, log) and returns: splits