code: def create_caltech_101_disk_folder(
      input_path: str, output_path: str, num_train_sample: int = 30
  ):
      """
      Following the VTAB protocol, we create a train and test split of
      such that:
      - 30 images of each cateogy end up in the training set
      - the remaining images end up in the test set
      """
      np.random.seed(0)
      labels = os.listdir(input_path)
      for label in tqdm(labels):
          label_path = os.path.join(input_path, label)
          file_names = sorted(os.listdir(label_path))
          train_indices = set(
              np.random.choice(
                  len(file_names), size=num_train_sample, replace=False
              )
          )
          train_output_path = os.path.join(output_path, "train", label)
          test_output_path = os.path.join(output_path, "test", label)
          os.makedirs(train_output_path, exist_ok=True)
          os.makedirs(test_output_path, exist_ok=True)
          for sample_index, file_name in enumerate(file_names):
              destination = (
                  train_output_path
                  if sample_index in train_indices
                  else test_output_path
              )
              output_file_name = _add_missing_extension(file_name)
              shutil.copy(
                  src=os.path.join(label_path, file_name),
                  dst=os.path.join(destination, output_file_name),
              )
  
file_path: vissl/extra_scripts/datasets/create_caltech101_data_files.py
imports: import argparse
  import os
  import shutil
  import numpy
  from torchvision.datasets.utils import extract_archive
  from tqdm import tqdm
  from vissl.utils.download import download_google_drive_url, get_redirected_url, to_google_drive_download_url
  from vissl.utils.io import cleanup_dir
label_desc: Use image node_id 3 for calling a global function with example usage: create_caltech_101_disk_folder(input_path, output_path, num_train_sample) without return types