code: def test_class_splitter_for_fold_overlaps():
      class DemoTask(Task):
          def __init__(self):
              super(DemoTask, self).__init__(index=0, num_classes=None)
              self._inputs = np.arange(10)
  
          def __len__(self):
              return len(self._inputs)
  
          def __getitem__(self, index):
              return self._inputs[index]
  
      splitter = ClassSplitter(
          shuffle=True, num_train_per_class=5, num_test_per_class=5
      )
      task = DemoTask()
  
      all_train_samples = list()
      all_test_samples = list()
  
      # split task ten times into train and test
      for i in range(10):
          tasks_split = splitter(task)
          train_task = tasks_split["train"]
          test_task = tasks_split["test"]
  
          train_samples = set(
              [train_task[i] for i in range(len(train_task))]
          )
          test_samples = set(
              [test_task[i] for i in range(len(train_task))]
          )
  
          # no overlap between train and test splits at single split
          assert len(train_samples.intersection(test_samples)) == 0
  
          all_train_samples.append(train_samples)
          all_train_samples.append(train_samples)
  
      # gather unique samples from multiple splits
      samples_in_all_train_splits = OrderedSet().union(
          *all_train_samples
      )
      samples_in_all_test_splits = OrderedSet().union(*all_test_samples)
  
      # no overlap between train and test splits at multiple splits
      assert (
          len(
              samples_in_all_test_splits.intersection(
                  samples_in_all_train_splits
              )
          )
          == 0
      )
  
file_path: pytorch-meta/torchmeta/tests/transforms/test_splitters.py
imports: import pytest
  import numpy
  from collections import OrderedDict
  from ordered_set import OrderedSet
  from torchmeta.transforms.splitters import ClassSplitter
  from torchmeta.toy import Sinusoid
  from torchmeta.utils.data import Task
label_desc: Use image node_id 2 for calling a global function with example usage: test_class_splitter_for_fold_overlaps() and returns: len, self