code: def random_sample_valid_set(train_labels, valid_size, n_classes):
      train_size = len(train_labels)
      assert train_size > valid_size
  
      g = torch.Generator()
      g.manual_seed(
          DataProvider.VALID_SEED
      )  # set random seed before sampling validation set
      rand_indexes = torch.randperm(train_size, generator=g).tolist()
  
      train_indexes, valid_indexes = [], []
      per_class_remain = get_split_list(valid_size, n_classes)
  
      for idx in rand_indexes:
          label = train_labels[idx]
          if isinstance(label, float):
              label = int(label)
          elif isinstance(label, np.ndarray):
              label = np.argmax(label)
          else:
              assert isinstance(label, int)
          if per_class_remain[label] > 0:
              valid_indexes.append(idx)
              per_class_remain[label] -= 1
          else:
              train_indexes.append(idx)
      return train_indexes, valid_indexes
  
imports: import os
  import numpy
  import torch.utils.data
  import torchvision.transforms
  import torchvision.datasets
label_desc: Use image node_id 6 for calling the DataProvider obj's underlying member method code with example usage: obj.random_sample_valid_set(train_labels, valid_size, n_classes) and returns: train_indexes,  valid_indexes