text: from numpy import empty
  from torchvision.datasets import CIFAR10, CIFAR100
  import os
  import pandas as pd
  import random
  import shutil
  import sys
  from array import array
  
  
  percentages = [0.05, 0.1, 0.2, 0.35, 0.5, 0.7]
  
  def create_directories(dataset_name, percentages):
      folder_names_and_percentages = []
      for percentage in percentages:
          folder_name  = dataset_name + "_" + str(int(percentage * 100)) + "%"
          os.makedirs(folder_name, exist_ok = True)
          folder_names_and_percentages.append((percentage, folder_name))
  
      return folder_names_and_percentages
  
  # ensure this script is ran from the PyTorch-StudioGAN directory (python3 src/data_starvation.py)
  def complete_cifar10_infra():
      # create folder structure for each different percetage of training data to be used
      os.chdir("data")
      empty_folders_and_percentages = create_directories("cifar-10", percentages)
      
  
      os.chdir("cifar-10_100%")
      os.rename("test", "valid")
  
      # get names of classes in dataset and training and validation filenames
      data_classes = os.listdir("train")
      all_train_filenames = os.listdir("train/" + data_classes[0])
      all_valid_filenames = os.listdir("valid/" + data_classes[0])
  
      os.chdir("../")
  
      # create folder structure for data folders
      for percentage, directory in empty_folders_and_percentages:
          os.chdir(directory)
          os.mkdir("train")
          os.mkdir("valid")
  
          for data_class in data_classes:
              os.mkdir("train/" + data_class)
              os.mkdir("valid/" + data_class)
          
          os.chdir("../")
  
      # from the full dataset, copy the correct percentage fo files to the correct folder destination
      os.chdir("cifar-10_100%")
  
      for percentage, directory in empty_folders_and_percentages:
              train_files_to_copy = random.sample(all_train_filenames, round(percentage * len(all_train_filenames)))
              valid_files_to_copy = random.sample(all_valid_filenames, round(percentage * len(all_valid_filenames)))
              for data_class in data_classes:
                  train_destination = "../../../" + directory + "/" + "train" + "/" + data_class
                  
                  os.chdir("train" + "/" + data_class)
                  for file in train_files_to_copy:
                      shutil.copy(file, train_destination)
                  os.chdir("../../")
  
                  valid_destination = "../../../" + directory + "/" + "valid" + "/" + data_class
  
                  os.chdir("valid" + "/" + data_class)
                  for file in valid_files_to_copy:
                      shutil.copy(file, valid_destination)
                  os.chdir("../../")
  
  
  def complete_cifar10_infra_updated_valid():
      # create folder structure for each different percetage of training data to be used
      os.chdir("data")
      empty_folders_and_percentages = create_directories("cifar-10", percentages)
      
  
      os.chdir("cifar-10_100%")
      os.rename("test", "valid")
  
      # get names of classes in dataset and training and validation filenames
      data_classes = os.listdir("train")
      all_train_filenames = os.listdir("train/" + data_classes[0])
      all_valid_filenames = os.listdir("valid/" + data_classes[0])
  
      os.chdir("../")
  
      # create folder structure for data folders
      for percentage, directory in empty_folders_and_percentages:
          os.chdir(directory)
          os.mkdir("train")
          os.mkdir("valid")
  
          for data_class in data_classes:
              os.mkdir("train/" + data_class)
              os.mkdir("valid/" + data_class)
          
          os.chdir("../")
  
      # from the full dataset, copy the correct percentage fo files to the correct folder destination
      os.chdir("cifar-10_100%")
  
      for percentage, directory in empty_folders_and_percentages:
              train_files_to_copy = random.sample(all_train_filenames, round(percentage * len(all_train_filenames)))
              valid_files_to_copy = random.sample(all_valid_filenames, round(percentage * len(all_valid_filenames)))
              
              for data_class in data_classes:
                  train_destination = "../../../" + directory + "/" + "train" + "/" + data_class
                  
                  os.chdir("train" + "/" + data_class)
                  for file in train_files_to_copy:
                      shutil.copy(file, train_destination)
                  os.chdir("../../")
  
                  valid_destination = "../../../" + directory + "/" + "valid" + "/" + data_class
  
                  os.chdir("valid" + "/" + data_class)
                  for file in all_valid_filenames:
                      shutil.copy(file, valid_destination)
                  os.chdir("../../")
  
  
  def complete_mnist_infra_updated_valid():
      # create folder structure for each different percetage of training data to be used
      os.chdir("data")
      empty_folders_and_percentages = create_directories("mnist", percentages)
      
  
      os.chdir("mnist_100%")
  
      # get names of classes in dataset and training and validation filenames
      all_train_filenames = {}
      all_valid_filenames = {}
      data_classes = os.listdir("train")
  
      for data_class in data_classes:
          all_train_filenames[data_class] = os.listdir("train/" + data_class)
  
      
      for data_class in data_classes:
          all_valid_filenames[data_class] = os.listdir("valid/" + data_class)
  
      os.chdir("../")
  
      # create folder structure for data folders
      for percentage, directory in empty_folders_and_percentages:
          os.chdir(directory)
          os.mkdir("train")
          os.mkdir("valid")
  
          for data_class in data_classes:
              os.mkdir("train/" + data_class)
              os.mkdir("valid/" + data_class)
          
          os.chdir("../")
  
      # from the full dataset, copy the correct percentage fo files to the correct folder destination
      os.chdir("mnist_100%")
  
      for percentage, directory in empty_folders_and_percentages:
              
              
              
              for data_class in data_classes:
                  train_destination = "../../../" + directory + "/" + "train" + "/" + data_class
                  train_files_to_copy = random.sample(all_train_filenames[data_class], round(percentage * len(all_train_filenames[data_class])))
                  os.chdir("train" + "/" + data_class)
  
                  for file in train_files_to_copy:
                      shutil.copy(file, train_destination)
                  os.chdir("../../")
  
                  valid_destination = "../../../" + directory + "/" + "valid" + "/" + data_class
                  valid_files_to_copy = all_valid_filenames[data_class]
                  os.chdir("valid" + "/" + data_class)
                  
                  for file in valid_files_to_copy:
                      shutil.copy(file, valid_destination)
                  os.chdir("../../")
  
  
      
  
  if __name__ == "__main__":
      complete_mnist_infra_updated_valid()
      