docstr: Create output directories where we write out the images.
  
  :args:
      labels (str) : the labels for the image
      data (np.array) : the binary array corresponding to the image
      output_dir (str) : the output directory that we need to write to
      path (str): the raw dataset path
  :returns:
      A tuple of the label for the image, the file array, the size and rows and columns for the image
docstr_tok: ["Create","output","directories","where","we","write","out","the","images",".",":","args",":","labels","(","str",")",":","the","labels","for","the","image","data","(","np.array",")",":","the","binary","array","corresponding","to","the","image","output_dir","(","str",")",":","the","output","directory","that","we","need","to","write","to","path","(","str",")",":","the","raw","dataset","path",":","returns",":","A","tuple","of","the","label","for","the","image",",","the","file","array",",","the","size","and","rows","and","columns","for","the","image"]
code: def write_output_dataset(self, labels, images, output_dir):
      """Create output directories where we write out the images.
  
      :args:
          labels (str) : the labels for the image
          data (np.array) : the binary array corresponding to the image
          output_dir (str) : the output directory that we need to write to
          path (str): the raw dataset path
      :returns:
          A tuple of the label for the image, the file array, the size and rows and columns for the image
      """
      # create child image output directories
      output_dirs = [
          os.path.join(output_dir, str(i)) for i in range(NUM_LABELS)
      ]
  
      for output_dir in output_dirs:
          makedirs(output_dir, exist_ok=True)
  
      def write_processed_image(t):
          i, label = t
          output_filename = os.path.join(
              output_dirs[label], str(i) + ".png"
          )
          torch_image = torch.from_numpy(images[i].copy()).view(
              1, 28, 28
          )
          self.write_png(torch_image, output_filename)
  
      # write out image data
      tasks = list(enumerate(labels))
      pool = ThreadPool(NUM_LABELS)
      pool.map(write_processed_image, tasks)
      pool.close()
      pool.join()
  
file_path: ludwig/ludwig/datasets/loaders/mnist.py
imports: import logging
  import os
  import struct
  from multiprocessing.pool import ThreadPool
  from typing import List, Optional
  import numpy
  import pandas
  import torch
  from ludwig.datasets.dataset_config import DatasetConfig
  from ludwig.datasets.loaders.dataset_loader import DatasetLoader
  from ludwig.utils.fs_utils import makedirs
label_desc: Use image node_id 5 for calling the MNISTLoader obj's underlying member method code with example usage: obj.write_output_dataset(labels, images, output_dir) without return types