code: def splitDatasets(
      dataset,
      id2label,
      test_ratio=0.15,
      balanced=True,
      augmentation=False,
  ):
      print("Split Datasets...")
  
      # If balanced is enabled
      if balanced == True:
          print("Balance train dataset...")
  
          ct = Counter(dataset.targets)
  
          # Balance the train dataset
          dataset = VisionDataset.__balance(dataset, ct)
  
      indices = torch.randperm(len(dataset)).tolist()
  
      # Index of the validation corpora
      train_index = math.floor(len(indices) * (1 - test_ratio))
  
      # Train set
      train_ds = torch.utils.data.Subset(dataset, indices[:train_index])
      print("Training Dataset Elements: ", len(train_ds))
  
      # If data augmentation is enabled
      if augmentation == True:
          new_ds = []
  
          # For each annotated image
          for img, label in train_ds:
              # Augment it
              new_ds.append((VisionDataset.__augmentation(img), label))
  
          # Replace by the augmented data
          train_ds = new_ds
  
      # Test set
      test_ds = torch.utils.data.Subset(dataset, indices[train_index:])
  
      ct_train = Counter(list(map(itemgetter(1), train_ds)))
      train_classes = [ct_train[int(a)] for a in list(id2label.keys())]
  
      ct_test = Counter(list(map(itemgetter(1), test_ds)))
      test_classes = [ct_test[int(a)] for a in list(id2label.keys())]
  
      table_distribution = [
          ["Train"] + train_classes + [str(len(train_ds))],
          ["Test"] + test_classes + [str(len(test_ds))],
      ]
  
      distribution_table = tabulate(
          table_distribution,
          ["Dataset"] + list(id2label.values()) + ["Total"],
          tablefmt="pretty",
      )
      print(distribution_table)
  
      # # Write logs
      # self.logs_file.write(distribution_table + "\n")
  
      return torch.utils.data.Subset(
          train_ds, list(range(0, len(train_ds)))
      ), torch.utils.data.Subset(test_ds, list(range(0, len(test_ds))))
  
file_path: HugsVision/hugsvision/dataio/VisionDataset.py
imports: import math
  import random
  from collections import Counter
  from operator import itemgetter
  import torch
  from torchvision import transforms
  from torchvision.datasets import ImageFolder
  from PIL import Image, ImageEnhance
  from tabulate import tabulate
label_desc: Use image node_id 3 for calling the VisionDataset obj's underlying member method code with example usage: obj.splitDatasets(dataset, id2label, test_ratio, balanced, augmentation) and returns: torch,  torch