code: def test_create_cache(
      test_data_csv_csv_20,
      test_data_csv_png_20,
      input_file_fmt,
      cache_file_fmt,
      shuffle,
      normalize,
      num_of_threads,
  ):
      if input_file_fmt == "csv":
          csvfilename = test_data_csv_csv_20
      else:
          csvfilename = test_data_csv_png_20
  
      nnabla_config.set(
          "DATA_ITERATOR", "cache_file_format", cache_file_fmt
      )
  
      with create_temp_with_dir() as tmpdir:
          cc = CreateCache(
              csvfilename,
              shuffle=shuffle,
              num_of_threads=num_of_threads,
          )
          cc.create(tmpdir, normalize=normalize)
  
          # get cache data source and csv file data source
          with closing(CacheDataSource(tmpdir)) as cache_source:
              csv_source = CsvDataSource(
                  csvfilename, normalize=normalize
              )
  
              check_relative_csv_file_result(
                  cache_file_fmt, csvfilename, tmpdir
              )
  
              assert cache_source.size == csv_source.size
              assert set(cache_source.variables) == set(
                  csv_source.variables
              )
  
              if shuffle:
                  with open(
                      os.path.join(tmpdir, "order.csv"), "r"
                  ) as f:
                      csv_source._order = [
                          int(row[1]) for row in csv.reader(f)
                      ]
  
              for _ in range(cache_source.size):
                  cache_data = associate_variables_and_data(
                      cache_source
                  )
                  csv_data = associate_variables_and_data(csv_source)
  
                  for v in cache_source.variables:
                      assert_allclose(cache_data[v], csv_data[v])
  
file_path: nnabla/python/test/utils/test_create_cache.py
imports: from __future__ import absolute_import
  import os
  import csv
  import pytest
  import tempfile
  from shutil import rmtree
  from contextlib import contextmanager, closing
  from nnabla.config import nnabla_config
  from nnabla.utils.create_cache import CreateCache
  from nnabla.utils.data_source_implements import CacheDataSource, CsvDataSource
  from nnabla.testing import assert_allclose
  from .conftest import test_data_csv_csv_20, test_data_csv_png_20
label_desc: Use image node_id 4 for calling a global function with example usage: test_create_cache(test_data_csv_csv_20, test_data_csv_png_20, input_file_fmt, cache_file_fmt, shuffle, normalize, num_of_threads) without return types