class_docstr: Utility class containing functions to load cluster assignments from files
  and visualize them or export them to different formats
class_docstr_tok: ["Utility","class","containing","functions","to","load","cluster","assignments","from","files","and","visualize","them","or","export","them","to","different","formats"]
docstr: Create a 'disk_filelist' dataset out of the cluster assignments:
  - the inputs are the images
  - the labels are the index of the cluster assigned to the image
docstr_tok: ["Create","a","'disk_filelist","'","dataset","out","of","the","cluster","assignments",":","-","the","inputs","are","the","images","-","the","labels","are","the","index","of","the","cluster","assigned","to","the","image"]
code: def save_cluster_assignment_as_dataset(
      cls, output_dir: str, assignments: ClusterAssignment
  ):
      """
      Create a 'disk_filelist' dataset out of the cluster assignments:
      - the inputs are the images
      - the labels are the index of the cluster assigned to the image
      """
      os.makedirs(output_dir, exist_ok=True)
      for split in assignments.cluster_assignments.keys():
          dataset = build_dataset(assignments.config, split)
          image_paths = dataset.get_image_paths()
          assert (
              len(image_paths) == 1
          ), "Multi-dataset not supported yet!"
          image_paths = image_paths[0]
  
          image_labels = []
          for image_id in range(len(image_paths)):
              image_labels.append(
                  assignments.cluster_assignments[split][image_id]
              )
  
          images_file_path = os.path.join(
              output_dir, f"{split.lower()}_images.npy"
          )
          labels_file_path = os.path.join(
              output_dir, f"{split.lower()}_labels.npy"
          )
          np.save(images_file_path, np.array(image_paths))
          np.save(labels_file_path, np.array(image_labels))
  
file_path: vissl/vissl/utils/cluster_utils.py
imports: import os
  from dataclasses import dataclass
  from typing import Dict, List
  import numpy
  import torch
  from iopath.common.file_io import g_pathmgr
  from vissl.config import AttrDict
  from vissl.data import build_dataset
label_desc: Use image node_id 3 for calling the ClusterAssignmentLoader obj's underlying member method code with example usage: obj.save_cluster_assignment_as_dataset(cls, output_dir, assignments) without return types