code: def create_sun397_disk_filelist_dataset(
      input_path: str, output_path: str, seed: int
  ):
      """
      Create partitions "train", "trainval", "val", "test" from the input path of SUN397
      by allocating 70% of labels to "train", 10% to "val" and 20% to "test".
      """
      random.seed(seed)
      g_pathmgr.mkdirs(output_path)
  
      # List all the available classes in SUN397 and their path
      image_folder = os.path.join(input_path, "SUN397")
      class_names_file = os.path.join(image_folder, "ClassName.txt")
      class_paths = []
      with open(class_names_file, "r") as f:
          for line in f:
              path = line.strip()
              if path.startswith("/"):
                  path = path[1:]
              class_paths.append(path)
  
      # For each label, split the samples in train/val/test and add them
      # to the list of samples associated to each split
      splits_data = {
          "train": SplitData(),
          "val": SplitData(),
          "test": SplitData(),
          "trainval": SplitData(),
      }
      for i, class_path in tqdm(
          enumerate(class_paths), total=len(class_paths)
      ):
          full_class_path = os.path.join(image_folder, class_path)
          image_names = os.listdir(full_class_path)
          splits = split_sample_list(image_names)
          for split, images in splits.items():
              for image_name in images:
                  image_path = os.path.join(full_class_path, image_name)
                  splits_data[split].image_paths.append(image_path)
                  splits_data[split].image_labels.append(i)
  
      # Save each split
      for split, samples in splits_data.items():
          image_output_path = os.path.join(
              output_path, f"{split}_images.npy"
          )
          with g_pathmgr.open(image_output_path, mode="wb") as f:
              np.save(f, np.array(samples.image_paths))
          label_output_path = os.path.join(
              output_path, f"{split}_labels.npy"
          )
          with g_pathmgr.open(label_output_path, mode="wb") as f:
              np.save(f, np.array(samples.image_labels))
  
file_path: vissl/extra_scripts/datasets/create_sun397_data_files.py
imports: import argparse
  import dataclasses
  import os
  import random
  from typing import Any, List
  import numpy
  from iopath.common.file_io import g_pathmgr
  from tqdm import tqdm
  from vissl.utils.download import download_and_extract_archive
label_desc: Use image node_id 4 for calling a global function with example usage: create_sun397_disk_filelist_dataset(input_path, output_path, seed) without return types