class_docstr: Create dataset cache from local file.
  
  If you want to create cache data from remote resource, use data_iterator_csv_dataset instead.
class_docstr_tok: ["Create","dataset","cache","from","local","file",".","If","you","want","to","create","cache","data","from","remote","resource",",","use","data_iterator_csv_dataset","instead","."]
code: def __init__(
      self,
      input_csv_filename,
      rng=None,
      shuffle=False,
      num_of_threads=None,
  ):
      self._cache_size = int(
          nnabla_config.get(
              "DATA_ITERATOR", "data_source_file_cache_size"
          )
      )
      logger.info("Cache size is {}".format(self._cache_size))
  
      self._filereader = FileReader(input_csv_filename)
      self._original_source_uri = input_csv_filename
      if rng is None:
          self._rng = numpy.random.RandomState(313)
      else:
          self._rng = rng
      self._shuffle = shuffle
  
      # read index.csv
      self._file = open(input_csv_filename, "r", encoding="utf-8-sig")
      csvreader = csv.reader(self._file)
  
      header = next(csvreader)
  
      # Store file positions of each data.
      self._csv_data = list(csvreader)
      self._size = len(self._csv_data)
  
      self._file.close()
  
      self._remove_comment_cols(header, self._csv_data)
      self._process_header(header)
      self._variables = tuple(self._variables_dict.keys())
  
      self._original_order = list(range(self._size))
  
      # Shuffle, the order is processing csv file order
      if self._shuffle:
          self._order = list(
              self._rng.permutation(list(range(self._size)))
          )
      else:
          self._order = list(range(self._size))
  
      if num_of_threads:
          self._num_of_threads = num_of_threads
      else:
          self._num_of_threads = int(
              nnabla_config.get(
                  "DATA_ITERATOR",
                  "data_source_file_cache_num_of_threads",
              )
          )
      logger.info("Num of thread is {}".format(self._num_of_threads))
  
file_path: nnabla/python/src/nnabla/utils/create_cache.py
imports: import collections
  import csv
  import os
  import shutil
  from contextlib import closing
  from multiprocessing.pool import ThreadPool
  import h5py
  import numpy
  from nnabla.config import nnabla_config
  from nnabla.logger import logger
  from nnabla.utils.data_source_implements import CsvDataSource
  from nnabla.utils.data_source_loader import FileReader
  from nnabla.utils.progress import progress
  from nnabla.utils.communicator_util import single_or_rankzero
label_desc: Use image node_id 2 to create a new CreateCache object from inherited base classes: CsvDataSource with example: obj = CreateCache(input_csv_filename, rng, shuffle, num_of_threads)